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

Re: I don't want the .git directory next to my code.

From
Jakub Narebski <jnareb@gmail.com>
Date
Jan 16, 2008, 13:13 UTC
Message-ID
<m3bq7lncak.fsf@roke.D-201>
In-Reply-To
<478D79BD.7060006@talkingspider.com>
Mike <fromlists@talkingspider.com> writes:
Show 7 quoted lines
> I'm learning git and I'm really annoyed that the .git directory lives
> in the same directory as my code.  I don't want it there for three
> reasons:
> 
> 1. My code lives on a development web server docroot, and I don't want
> the .git repository to end up getting published to the live site by
> accident. (I would imagine this would be a common need.)

Use git-archive (or, in older releases, git-tar-tree) and perhaps post-update / post-recieve hook to publish latest version.

I think best layout would be: 
 (1) your private copy (clone) of repository, with working directory
 (2) bare (without working directory) publishing repository,
     with post-update hook
 (3) published last version of your files
You can check 'todo' branch of git.git repository for scripts which
Junio uses to automatically update git HTML documentation at
kernel.org
 
> 2. If I tar/gz my code and deliver it to a client, I don't want the
> .git dir slipping into the tarball, allowing my client to be able to
> peruse the history of what we did and when.
Use git-archive / git-tar-tree to tar.gz or zip code to send to client.
This has the advantage of not packing generated code, backup files,
etc., not only .git. Besides there is --exclude option to tar ;-)
 
(For RPM based distributions git-archive is usually in git-core;
I don't know what package you have to install on Debian based distro).
Show 7 quoted lines
> 3. The .git respository will get big, especially with binary files in
> it, and I want it someplace with a lot of disk space. And I don't want
> it to get tarred up when we migrate the site to a different
> server. (And tar isn't aware of hard links is it? wonderful.)
> 
> How do I make the repository dir live somewhere else, the hell away
> from my code? Thanks

If you are inside repo, configuration variable core.worktree, environmental variable GIT_WORK_DIR, or '--work-tree' command line option (git --work-tree=/path/to/working/dir <cmd>) can be used to point to working tree.

If you are in working area, environmental variable GIT_DIR, or '--git-dir' command line option can be used to point to the repository. You can also symlink .git in working directory. There was an idea of '.gitlink' file, similar to CVS/Root file in CVS, or core.gitdir configuration variable which points to base GIT_DIR in unionfs / shadow like way, but neither got implemented. You are welcome to it... of course after release :-)

-- 
Jakub Narebski
Poland
ShadeHawk on #git
Previous: Johannes SchindelinNext: Brian Downing
Message 61 of 65 in “I don't want the .git directory next to my code.”
  1. MikeJan 16, 2008
  2. Randal L. SchwartzJan 16, 2008
  3. MikeJan 16, 2008
  4. David SymondsJan 16, 2008
  5. MikeJan 16, 2008
  6. SeanJan 16, 2008
  7. MikeJan 16, 2008
  8. Neil MacnealeJan 16, 2008
  9. MikeJan 16, 2008
  10. Johannes SchindelinJan 16, 2008
  11. Linus TorvaldsJan 16, 2008
  12. Linus TorvaldsJan 16, 2008
  13. MikeJan 17, 2008
  14. Kris ShannonJan 17, 2008
  15. Wincent ColaiutaJan 17, 2008
  16. Jeff KingJan 17, 2008
  17. Linus TorvaldsJan 17, 2008
  18. Johannes SchindelinJan 17, 2008
  19. Linus TorvaldsJan 17, 2008
  20. Johannes SchindelinJan 17, 2008
  21. MikeJan 17, 2008
  22. Johannes SchindelinJan 17, 2008
  23. MikeJan 17, 2008
  24. Johannes SchindelinJan 17, 2008
  25. MikeJan 17, 2008
  26. Johannes SchindelinJan 17, 2008
  27. MikeJan 17, 2008
  28. Johannes SchindelinJan 17, 2008
  29. David SymondsJan 18, 2008
  30. Russ DillJan 22, 2008
  31. Martin LanghoffJan 17, 2008
  32. Andreas EricssonJan 18, 2008
  33. Junio C HamanoJan 16, 2008
  34. Ping YinJan 17, 2008
  35. Linus TorvaldsJan 17, 2008
  36. Dan McGeeJan 16, 2008
  37. MikeJan 16, 2008
  38. Mike KrierJan 16, 2008
  39. MikeJan 16, 2008
  40. Nguyen Thai Ngoc DuyJan 16, 2008
  41. David SymondsJan 16, 2008
  42. MikeJan 16, 2008
  43. Daniel BarkalowJan 16, 2008
  44. Luke LuJan 16, 2008
  45. MikeJan 16, 2008
  46. Sam VilainJan 17, 2008
  47. Daniel BarkalowJan 16, 2008
  48. MikeJan 16, 2008
  49. Johannes SchindelinJan 16, 2008
  50. Bert WesargJan 16, 2008
  51. Wayne DavisonJan 16, 2008
  52. Matthieu MoyJan 16, 2008
  53. Johannes SchindelinJan 16, 2008
  54. Bill LearJan 16, 2008
  55. Matthieu MoyJan 16, 2008
  56. Johannes SchindelinJan 16, 2008
  57. Junio C HamanoJan 16, 2008
  58. Johannes SchindelinJan 16, 2008
  59. Matthieu MoyJan 16, 2008
  60. Johannes SchindelinJan 16, 2008
  61. Jakub NarebskiJan 16, 2008
  62. Brian DowningJan 17, 2008
  63. Randal L. SchwartzJan 17, 2008
  64. Martin LanghoffJan 17, 2008
  65. Randal L. SchwartzJan 17, 2008

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.