Skip to contentSkip to conversation

Use of Git with local folders

DISCUSSION Felipe Bustamante 4 participants 7 messages Apr 25, 2024 – Apr 29, 2024

lore
Share & tools
lore
#0 lore raw

Hi,

I would like to know if it is possible to combine the contents of several directories with copies of the same source code but with different changes?

The stage is:
1. There is a directory with the original source code, without changes.
2. There are several directories, ordered by the date of creation, which are a copy of the original source code, copies made every day after generating changes, that is, the original source code resides in the DIR1 directory, a copy is made with name dir2, and changes are made to the source code of the project. The next day, a copy of the directory of name DIR2 is made and renamed DIR3, we work with this directory making changes to the source code. The same process is carried out for two weeks.

The important question would be, is it possible to combine these directories in a repository with a Master branch (the first original directory (DIR1) and transform the other directory into branches of the master?

It would be useful, if copies were made that were made on an original directory (dir1) that was already becoming a git repository, with the use of Visual Studio 2022?

As an observation, the work is done on an isolated computer, without internet connection or to backup devices, the computer is fully isolated and it is necessary to generate the version control, in the case that it is possible.

Any orientation in this regard would be very useful.

Thanks,

Felipe Bustamante
Sverige

--
This email has been checked for viruses by AVG antivirus software. www.avg.com

#1 lore raw

Hello Felipe,

Quoted 12 lines · Felipe Bustamante

Hi,

I would like to know if it is possible to combine the contents of several directories with copies of the same source code but with different changes?

The stage is:
1. There is a directory with the original source code, without changes.
2. There are several directories, ordered by the date of creation, which are a copy of the original source code, copies made every day after generating changes, that is, the original source code resides in the DIR1 directory, a copy is made with name dir2, and changes are made to the source code of the project. The next day, a copy of the directory of name DIR2 is made and renamed DIR3, we work with this directory making changes to the source code. The same process is carried out for two weeks.

The important question would be, is it possible to combine these directories in a repository with a Master branch (the first original directory (DIR1) and transform the other directory into branches of the master?

It would be useful, if copies were made that were made on an original directory (dir1) that was already becoming a git repository, with the use of Visual Studio 2022?

Quoted 9 lines

As an observation, the work is done on an isolated computer, without internet connection or to backup devices, the computer is fully isolated and it is necessary to generate the version control, in the case that it is possible.

Any orientation in this regard would be very useful.

Thanks,

Felipe Bustamante
Sverige

I'm not sure I fully grasp the problem, especially around why these copies are made in such a way.

But, have you looked at 'git-worktree'? This would allow you to do something like

$ cd dir1
$ git worktree add -b branch2 ../dir2

Once done with dir2, you can remove the worktree

$ git worktree remove ../dir2

But the branch ('branch2') would still remain and you can merge the branch as needed.

I hope that helps

- Karthik

#2 lore raw

Hi Karthik,

Thanks for the reply.

What you indicate allows me to create a relationship between a new branch and a new empty local directory, but what I need is to relate a branch with an existing local directory since the latter contains the changes made to the source code and I need to generate change control.

I am going to clarify the working conditions to explain why we have worked in this way.

The computer for development is in a completely isolated work environment, without connection to any data network, all data ports are disabled (network, USB, Bluetooth, etc.) so there is no possibility of copying the code. source towards a more open environment.

This computer only has Visual Studio 2022 installed, no other type of software has been installed, which is why it is impossible to create branches from the master since VS 2022 does not allow branches connected to local directories.

The only way that could be used to isolate daily changes was to create a directory each day, by means of a copy from Windows File Explorer, containing the changes made during the last and previous days.

The structure of the project would be as follows:

1. CS_2024-04-10 directory, this is the original directory containing the original source code. This directory was converted to a GIT repository using VS 2022 which allows us to have the master branch. Because of the above, this directory contains the hidden .git directory.
2. The next day, a copy of the original directory was made, and this copy was named CS_2024-04-11. Because of this, this directory contains the hidden .git directory of the original. We worked on this copy by opening the project in VS 2022 and making various changes and then saving the results.

3. The previous process has been carried out for two weeks, so there are 10 source code directories which include the changes made during each workday plus the changes from the respective previous day, for example, the directory CS_2024-04- 16 contains all the changes made from day 10 to day 15 plus the changes made during day 16.

Now, what we need is to know if it is possible to convert all these sequential directories into a GIT structure with change control such as the first directory with the master branch and then branches that can be associated with each subsequent directory.

I have installed, to support the idea, the GIT program. For this reason, now the development computer only contains two software for development, Visual Studio 2022, and GIT.

How would it be possible to create branches from the master branch, using the original directory CS_2024-04-10 and associate these branches with the sequential directories created?

Thank you very much for the help.

Felipe Bustamante
Sverige

-----Original Message-----
From: Karthik Nayak <[email protected]>
Sent: den 26 april 2024 12:16
To: Felipe Bustamante <[email protected]>; [email protected]
Subject: Re: Use of Git with local folders

Hello Felipe,

Quoted 12 lines · Felipe Bustamante

Hi,

I would like to know if it is possible to combine the contents of several directories with copies of the same source code but with different changes?

The stage is:
1. There is a directory with the original source code, without changes.
2. There are several directories, ordered by the date of creation, which are a copy of the original source code, copies made every day after generating changes, that is, the original source code resides in the DIR1 directory, a copy is made with name dir2, and changes are made to the source code of the project. The next day, a copy of the directory of name DIR2 is made and renamed DIR3, we work with this directory making changes to the source code. The same process is carried out for two weeks.

The important question would be, is it possible to combine these directories in a repository with a Master branch (the first original directory (DIR1) and transform the other directory into branches of the master?

It would be useful, if copies were made that were made on an original directory (dir1) that was already becoming a git repository, with the use of Visual Studio 2022?

Quoted 9 lines

As an observation, the work is done on an isolated computer, without internet connection or to backup devices, the computer is fully isolated and it is necessary to generate the version control, in the case that it is possible.

Any orientation in this regard would be very useful.

Thanks,

Felipe Bustamante
Sverige

I'm not sure I fully grasp the problem, especially around why these copies are made in such a way.

But, have you looked at 'git-worktree'? This would allow you to do something like

$ cd dir1
$ git worktree add -b branch2 ../dir2

Once done with dir2, you can remove the worktree

$ git worktree remove ../dir2

But the branch ('branch2') would still remain and you can merge the branch as needed.

I hope that helps

- Karthik

--
This email has been checked for viruses by AVG antivirus software. www.avg.com

#3 lore raw

Hi Felipe

[please don't top-post]

Quoted 64 lines · Felipe Bustamante

Hi Karthik,

Thanks for the reply.

What you indicate allows me to create a relationship between a new branch and a new empty local directory, but what I need is to relate a branch with an existing local directory since the latter contains the changes made to the source code and I need to generate change control.

I am going to clarify the working conditions to explain why we have worked in this way.

The computer for development is in a completely isolated work environment, without connection to any data network, all data ports are disabled (network, USB, Bluetooth, etc.) so there is no possibility of copying the code. source towards a more open environment.

This computer only has Visual Studio 2022 installed, no other type of software has been installed, which is why it is impossible to create branches from the master since VS 2022 does not allow branches connected to local directories.

The only way that could be used to isolate daily changes was to create a directory each day, by means of a copy from Windows File Explorer, containing the changes made during the last and previous days.

The structure of the project would be as follows:

1. CS_2024-04-10 directory, this is the original directory containing the original source code. This directory was converted to a GIT repository using VS 2022 which allows us to have the master branch. Because of the above, this directory contains the hidden .git directory. 2. The next day, a copy of the original directory was made, and this copy was named CS_2024-04-11. Because of this, this directory contains the hidden .git directory of the original. We worked on this copy by opening the project in VS 2022 and making various changes and then saving the results.

3. The previous process has been carried out for two weeks, so there are 10 source code directories which include the changes made during each workday plus the changes from the respective previous day, for example, the directory CS_2024-04- 16 contains all the changes made from day 10 to day 15 plus the changes made during day 16.

Now, what we need is to know if it is possible to convert all these sequential directories into a GIT structure with change control such as the first directory with the master branch and then branches that can be associated with each subsequent directory.

I have installed, to support the idea, the GIT program. For this reason, now the development computer only contains two software for development, Visual Studio 2022, and GIT.

How would it be possible to create branches from the master branch, using the original directory CS_2024-04-10 and associate these branches with the sequential directories created?

Thank you very much for the help.

Felipe Bustamante Sverige

Quoted 39 lines

-----Original Message----- From: Karthik Nayak <[email protected]> Sent: den 26 april 2024 12:16 To: Felipe Bustamante <[email protected]>; [email protected] Subject: Re:
Use of Git with local folders

Hello Felipe,

Quoted 31 lines · Felipe Bustamante

Hi,

I would like to know if it is possible to combine the contents of several directories with copies of the same source code but with different changes?

The stage is: 1. There is a directory with the original source code, without changes. 2. There are several directories, ordered by the date of creation, which are a copy of the original source code, copies made every day after generating changes, that is, the original source code resides in the DIR1 directory, a copy is made with name dir2, and changes are made to the source code of the project. The next day, a copy of the directory of name DIR2 is made and renamed DIR3, we work with this directory making changes to the source code. The same process is carried out for two weeks.

The important question would be, is it possible to combine these directories in a repository with a Master branch (the first original directory (DIR1) and transform the other directory into branches of the master?

It would be useful, if copies were made that were made on an original directory (dir1) that was already becoming a git repository, with the use of Visual Studio 2022?

As an observation, the work is done on an isolated computer, without internet connection or to backup devices, the computer is fully isolated and it is necessary to generate the version control, in the case that it is possible.

Any orientation in this regard would be very useful.

What would work in my opinion is this, if I understand you correctly:

1. In the Git repo of day 1, remove all files except for the .git folder. This is to make sure that any files that are no longer present on the next day are really no longer in the repo.

2. Copy the content of day 2 except the .git folder over into day 1. git status, git diff etc should show the differences between days 1 and 2.

3. Create a new branch for this day, and commit all changes.

4. Continue from step 1 for each remaining day.

This will result in one repository that has one commit per day. Going forward, you'd probably want to commit more often so that your commits comprise a meaningful unit of work instead of arbitrary day boundaries.

It does not matter that your system is air-gapped. Git works perfectly locally without ever fetching or pushing.

By the way, I don't think it's necessary to create a new branch each day; you can inspect the history just as well by only committing.

HTH

Signature · 1 line
Cheers, Beat
#4 lore raw
Quoted 10 lines · Beat Bolli

What would work in my opinion is this, if I understand you correctly:

1. In the Git repo of day 1, remove all files except for the .git folder. This is to make sure ...
4. Continue from step 1 for each remaining day.

This will result in one repository that has one commit per day. Going forward, you'd probably want to commit more often so that your commits comprise a meaningful unit of work instead of arbitrary day boundaries.

Hmph, perhaps I am misunderstanding things, but I didn't read in the original or the follow-up from the OP any wish to "squash" a day's worth of activities into a single commit each.

Let me make sure what I understood from the follow-up from the OP is not too far away from the reality. I thought the day's activity is

* The whole "repository + working tree" from day (N-1) is copied into a new "repository + working tree" for day N, to let the user to play in. Then the user hacks away, creating commits on top of the HEAD.

So there may be a directory structure

- FBustamante/
- Day-01/
- .git/
- COPYING
- ...
- Day-02/
- .git/
- COPYING
...
- Day-10/
- .git/
- COPYING
- ...

but Day-10/.git has ALL the history for everything. Day-10/.git is a superset of Day-09/.git, which in turn is a superset of Day-08/.git, etc. all the way down to Day-01/.git/.

If that is the case, and if the end state of each day needs to be given a "label" so that it is easily discoverable, then what I would do would be something like:

    $ cd FBustamante
    $ cp -a Day-10 ALL

to first prepare an exact copy of Day-10 in ALL, and then

    $ for d in Day-??
      do
	rev=$(git -C "$d" rev-parse HEAD)
	git -C ALL tag "$d" "$rev"
      done

to go in to each day's repository to grab its HEAD, and make a tag for that commit in the ALL repository.

Then doing the usual things like

    $ cd ALL
    $ git log Day-01
    $ git log Day-02..Day-04

should give us what happend on the first day, what happened on the third and fourth day, etc., as expected.

#5 lore raw
Quoted 8 lines · Junio C Hamano
Quoted 6 lines · Beat Bolli

What would work in my opinion is this, if I understand you correctly:

1. In the Git repo of day 1, remove all files except for the .git folder. This is to make sure ...
4. Continue from step 1 for each remaining day.

Quoted 9 lines
Quoted 4 lines

This will result in one repository that has one commit per day. Going forward, you'd probably want to commit more often so that your commits comprise a meaningful unit of work instead of arbitrary day boundaries.

Hmph, perhaps I am misunderstanding things, but I didn't read in the original or the follow-up from the OP any wish to "squash" a day's worth of activities into a single commit each.

I guess my brain just implied from those daily copies that there was just one commit at the end of the day.

Your explanation below makes more sense.

Quoted 56 lines

Let me make sure what I understood from the follow-up from the OP is not too far away from the reality. I thought the day's activity is

* The whole "repository + working tree" from day (N-1) is copied into a new "repository + working tree" for day N, to let the user to play in. Then the user hacks away, creating commits on top of the HEAD.

So there may be a directory structure

- FBustamante/
- Day-01/
- .git/
- COPYING
- ...
- Day-02/
- .git/
- COPYING
...
- Day-10/
- .git/
- COPYING
- ...

but Day-10/.git has ALL the history for everything. Day-10/.git is a superset of Day-09/.git, which in turn is a superset of Day-08/.git, etc. all the way down to Day-01/.git/.

If that is the case, and if the end state of each day needs to be given a "label" so that it is easily discoverable, then what I would do would be something like:

     $ cd FBustamante
     $ cp -a Day-10 ALL

to first prepare an exact copy of Day-10 in ALL, and then

     $ for d in Day-??
       do
	rev=$(git -C "$d" rev-parse HEAD)
	git -C ALL tag "$d" "$rev"
       done

to go in to each day's repository to grab its HEAD, and make a tag for that commit in the ALL repository.

Then doing the usual things like

     $ cd ALL
     $ git log Day-01
     $ git log Day-02..Day-04

should give us what happend on the first day, what happened on the third and fourth day, etc., as expected.

#6 lore raw

Hi Beat,

-----Original Message-----
From: Beat Bolli <[email protected]>
Sent: den 28 april 2024 00:03
To: Junio C Hamano <[email protected]>
Cc: Felipe Bustamante <[email protected]>; [email protected]; 'Karthik Nayak' <[email protected]>
Subject: Re: Use of Git with local folders

Quoted 8 lines · Junio C Hamano
Quoted 6 lines · Beat Bolli

What would work in my opinion is this, if I understand you correctly:

1. In the Git repo of day 1, remove all files except for the .git folder. This is to make sure ...
4. Continue from step 1 for each remaining day.

Quoted 9 lines
Quoted 4 lines

This will result in one repository that has one commit per day. Going forward, you'd probably want to commit more often so that your commits comprise a meaningful unit of work instead of arbitrary day boundaries.

Hmph, perhaps I am misunderstanding things, but I didn't read in the original or the follow-up from the OP any wish to "squash" a day's worth of activities into a single commit each.

I guess my brain just implied from those daily copies that there was just one commit at the end of the day.

Your explanation below makes more sense.

Quoted 46 lines

Let me make sure what I understood from the follow-up from the OP is not too far away from the reality. I thought the day's activity is

* The whole "repository + working tree" from day (N-1) is copied into a new "repository + working tree" for day N, to let the user to play in. Then the user hacks away, creating commits on top of the HEAD.

So there may be a directory structure

- FBustamante/
- Day-01/
- .git/
- COPYING
- ...
- Day-02/
- .git/
- COPYING
...
- Day-10/
- .git/
- COPYING
- ...

but Day-10/.git has ALL the history for everything. Day-10/.git is a superset of Day-09/.git, which in turn is a superset of Day-08/.git, etc. all the way down to Day-01/.git/.

If that is the case, and if the end state of each day needs to be given a "label" so that it is easily discoverable, then what I would do would be something like:

     $ cd FBustamante
     $ cp -a Day-10 ALL

to first prepare an exact copy of Day-10 in ALL, and then

     $ for d in Day-??
       do
	rev=$(git -C "$d" rev-parse HEAD)
	git -C ALL tag "$d" "$rev"
       done

to go in to each day's repository to grab its HEAD, and make a tag for that commit in the ALL repository.

Quoted 10 lines

Then doing the usual things like

     $ cd ALL
     $ git log Day-01
     $ git log Day-02..Day-04

should give us what happend on the first day, what happened on the third and fourth day, etc., as expected.

The technique suggested by Junio C Hamano resulted in a resf error when executing the for, which did not allow me to obtain the expected result.

On the other hand, the technique that you have suggested to me did give the expected results and now has a master and all the commits made for two weeks.

Thank you very much for the help, everyone,

Felipe Bustamante
Sverige

--
This email has been checked for viruses by AVG antivirus software. www.avg.com