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 filesYou 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