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

Re: [PATCH/RFC] init, clone: support --real-git-dir for .git file

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 4, 2011, 00:08 UTC
Message-ID
<7v8vwv927a.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1299156201-12149-1-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
> Instead of creating the repository at $GIT_DIR, --real-git-dir will
> tell git to put the repository there, then make $GIT_DIR a .git file
> that points to --real-git-dir.

Just like you, I am also bad at naming things, so I cannot offhand suggest a better name, even though I _know_ --real-git-dir sounds horrible.

The naming aside, the feature is what we have wanted to have for a long time and is way overdue. Thanks for showing how small-impact the necessary changes are.

"submodule init subpro" should be able to use this to clone a submodule with:

	git clone --xxx=.git/modules/subpro.git subpro

When we need to switch to a revision without that submodule, after making sure that there is no precious file in subpro/ directory, we would:

	rm -rf subpro/

Now, what do we need to switch back to a revision with that submodule? It would involve something like this:

	... after checking if we already have .git/modules/subpro.git
        ... and seeing that we do ...
	mkdir subpro
	commit=$(git rev-parse :subpro)
        echo 'gitdir: ../.git/modules/subpro.git' >subpro/.git
	cd subpro && git checkout $commit^0

The above four lines packaged for "git submodule" script would be a useful thing to have, especially because then nobody has to write the "echo" part.

>  I intend to make 'git init --real-git-dir' move current repo to
>  somewhere else if called on existing repo.

I don't know if that is useful in real life. Do you have a concrete use case (like the one I showed an example above) in mind?

Previous: Nguyen Thai Ngoc DuyNext: Miles Bader
Message 9 of 15 in “init, clone: support --real-git-dir for .git file”
  1. init, clone: support --real-git-dir for .git fileNguyễn Thái Ngọc Duy, Mar 3, 2011
  2. Piotr KrukowieckiMar 3, 2011
  3. Junio C HamanoMar 3, 2011
  4. Piotr KrukowieckiMar 4, 2011
  5. Nguyen Thai Ngoc DuyMar 4, 2011
  6. Piotr KrukowieckiMar 4, 2011
  7. Junio C HamanoMar 4, 2011
  8. Nguyen Thai Ngoc DuyMar 4, 2011
  9. Junio C HamanoMar 4, 2011
  10. Miles BaderMar 4, 2011
  11. Nguyen Thai Ngoc DuyMar 4, 2011
  12. Nguyen Thai Ngoc DuyMar 4, 2011
  13. Junio C HamanoMar 4, 2011
  14. Nguyen Thai Ngoc DuyMar 4, 2011
  15. Miles BaderMar 4, 2011

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.