tags:

views:

517

answers:

5

This question is asked out of curiosity more than for anything practical, but can I effectively have my $GIT_DIR be git://example.com/repo.git/ ? So there would be no .git folder -- every single commit, etc would go through the network overhead.

edit: One potential use case might be for trying to do a simple "export" like svn, but it turns out that question is answered here

+3  A: 

$GIT_DIR, introduced in May 2005, is for:

  • specifying both SHA1_FILE_DIRECTORY (was GIT_OBJECT_DIRECTORY, i.e. "$GIT_DIR/objects")
  • GIT_INDEX_FILE ("$GIT_DIR/index")

When GIT_DIR is not defined, it defaults to ".git".

It is meant to be an absolute path or relative path to current working directory, not an http or git absolute path.

Inspired by this post from Junio C. Hamano:

Some commands would not work in the later case.
For instance, "git diff <one-tree>" (representing a way to diff the part of work tree you are currently in with the given tree) would fail.
Note: this is not like "git diff" , which does the same with the index.
With these commands (and others that error out when you run without GIT_DIR outside the work tree), you are really expected to be in the subdirectory you are interested in. .

VonC
+1  A: 

No, it is not possible to have remote $GIT_DIR (nor it is possible to have remote repository in .git/objects/info/alternates). Git just doesn't work this way.

Jakub Narębski
+2  A: 

I would postulate that if you are asking this question, you may be trying to create a problem to solve.

Just think about why you would need to have a singular git repository people can read and write to directly from their own remote machines, and try add them to the question, because it seems for all the world you're trying to use Git like SVN. And that will end in agony.

For starters, if you don't want to make a complete deep mirror just for creating a patch for upstream, please make note of :

--depth <depth>
Create a shallow clone with a history truncated to the specified number of revisions. A shallow repository has a number of limitations (you cannot clone or fetch from it, nor push from nor into it), but is adequate if you are only interested in the recent history of a large project with a long history, and would want to send in fixes as patches. ( git help clone )

Kent Fredric
It's not that unreasonable. One area where Git struggles is with lots of very large files with lots of history changes. That is, where the .git/ directory is VERY large -- much larger (possibly) than the working copy. For example, .git may not fit on a laptop hard drive but the working copy might. Also, the poster never mentioned sharing that remote repository (which would be a problem)
Pat Notz
@Kent, I have to concur with @Pat Notz. I worry that you're rushing to the judgement that this is an "X Y" problem. Remember, just because you can't imagine a use case doesn't mean that it doesn't exist. But your answer is pretty darn useful, given the reality that Git just doesn't support this feature.
Ryan B. Lynch
+1  A: 

Like the others have noted, Git is not written to work this way. However, I think you could have your .git directory on a network mount. Perhaps you could mount the remote server as a file system like NFS or sshfs. That's not as general as you may like but it could possibly work for some situations.

Pat Notz
A: 

Possible (obtuse, but functional) solution: remotely mount the directory you want to work with, and soft-link your .git directory to the mount point.

Autocracy