threads / discuss / 58162

moving a repository question

Subject: moving a repository question

## tl;dr

4 messages between Jul 14, 2022 and Jul 15, 2022.

replies: 3people: 2as markdown or json

Paul Kinzelman· Jul 14, 2022, 22:06 UTC · lore

I barely qualify as a novice on git, so my apologies in advance if this is a stupid question.

Is everything that git needs stored in the .git tree?

In understanding the big picture... Is there any reason I can't just move or copy the entire .git tree someplace else if I wanted to move or make a copy?

I realize about the clone command, but wouldn't just a straight copy be easier (in the vanilla case where no branches or anything complicate things)? TIA! -Paul Kinzelman

Junio C Hamano· Jul 14, 2022, 22:59 UTC · re: Paul Kinzelman · lore

Re: moving a repository question

Paul Kinzelman <paul@kinzelman.com> writes:
> I barely qualify as a novice on git, so my apologies in advance if this is a
> stupid question.
>
> Is everything that git needs stored in the .git tree?
Depends on what you want to do with "Git".

If you only copy .git/ and no file from the working tree, your "git status" in the new location will report "you removed all the files and you have nothing", for example. If you are willing to do "git reset --hard" after making such a copy of ".git/", it may be OK. If you had local changes in the working tree before taking a copy of .git/, doing "git reset --hard" in the new location may not recover the local changes in the original, so it may not be good and you may have to copy the working tree files as well.

If you are using multiple worktrees linked to the repository, copying .git/ is an absolute no-no. Locations of secondary worktrees are recorded in .git/ somewhere and copying them literally would mean the new copy would mistakenly think that these secondary worktrees linked to the original repository are linked to the new copy instead. There may be other things that will cause confusions when copied.

"git clone" will of course sidestep all of these problems.
Paul Kinzelman· Jul 15, 2022, 16:59 UTC · re: Junio C Hamano · lore

Re: moving a repository question

Part of my question is just understanding git, it's different from another source control tool I've used.

The other part is if I'm having trouble networking computers together, I'm wondering if I could copy everything under .git to a flash drive, then write the tree to another PC, and expect everything to work? And when they are able to network with each other, they should be in sync (assuming vanilla, no changes, no uncommitted files, etc.), and I could modify a file on one machine and expect that the other copied tree would be able to fetch it?

Note, I'm talking a very vanilla case here, no complexity like you were mentioning, no branches, no uncommitted files, no multiple worktrees, no changes in files, no nothing. Just a straight simple single project.

On 7/14/2022 4:59 PM, Junio C Hamano wrote:
Show 26 quoted lines
> Paul Kinzelman <paul@kinzelman.com> writes:
>
>> I barely qualify as a novice on git, so my apologies in advance if this is a
>> stupid question.
>>
>> Is everything that git needs stored in the .git tree?
> Depends on what you want to do with "Git".
>
> If you only copy .git/ and no file from the working tree, your "git
> status" in the new location will report "you removed all the files
> and you have nothing", for example.  If you are willing to do "git
> reset --hard" after making such a copy of ".git/", it may be OK.  If
> you had local changes in the working tree before taking a copy of
> .git/, doing "git reset --hard" in the new location may not recover
> the local changes in the original, so it may not be good and you may
> have to copy the working tree files as well.
>
> If you are using multiple worktrees linked to the repository,
> copying .git/ is an absolute no-no.  Locations of secondary
> worktrees are recorded in .git/ somewhere and copying them literally
> would mean the new copy would mistakenly think that these secondary
> worktrees linked to the original repository are linked to the new
> copy instead.  There may be other things that will cause confusions
> when copied.
>
> "git clone" will of course sidestep all of these problems.
Paul Kinzelman· Jul 15, 2022, 18:27 UTC · re: Junio C Hamano · lore

RDP over VPN can't see a .git directory to be able to pull

I'm trying to 'git pull' between two W10 systems over a VPN with RDP.
I map my local C:\ drive to drive s:\ on the remote system so on the remote
system, I can see my local C:\ drive that has the repository
On the remote system, I do
     git pull s:\gitrepository
but it says
     ...does not appear to be a git repository, could not read from 
remote repository
In a command line window on the remote system, I do
     dir s:\gitrepository
and the .git directory is not shown in the listing. All the other files are
including the .gitignore file (has a dot at the start).
But I can do
     dir s:\gitrepository\.git
and all the files and subfolders under .git are there.

I've set the "Show hidden files, folders, and drives" radio button in the Folder Options | View window if that matters.

Any idea why the .git directory is being blocked from being seen unless specifically specified, but I can see the .gitignore file just fine?

← back to recent threads