git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: moving a repository question

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 14, 2022, 22:59 UTC
Message-ID
<xmqqilnz2tck.fsf@gitster.g>
In-Reply-To
<2e592944-edb8-2d49-981a-8ad220f97e82@kinzelman.com>
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.
Previous: Paul KinzelmanNext: Paul Kinzelman
Message 2 of 4 in “moving a repository question”
  1. Paul KinzelmanJul 14, 2022
  2. Junio C HamanoJul 14, 2022
  3. Paul KinzelmanJul 15, 2022
  4. RDP over VPN can't see a .git directory to be able to pullPaul Kinzelman, Jul 15, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.