开发者

How to have the working dir of a repo in another dir than the .git folder?

I have a repo in dir ~/myRepo/. Because I want to use this repo across multiple machines, I want to have the .git folder in my dir ~/Dropbox/.

I know, that there was some ability to create a file in ~/myRepo, which contains a path to开发者_如何学编程 the git-folder ~/Dropbox/myRepo.git, but I forgot which and cannot find the information in the man-pages.

Please don't tell me to simply ln -s the folder, I tried this and considered it impracticable.


Maybe you are looking for the “gitfile” functionality. It is briefly mentioned in gitrepository-layout(5):

… (… It is also possible to have a working tree where .git is a plain ASCII file containing gitdir: <path>, i.e. the path to the real git repository).

You do not say why symlinks will not work for you but the only advantage this has is that it will work in environments that do not support symlinks. It is effectively an application-level symlink (much like Git’s symbolic refs).

Make ~/myRepo/.git a normal file with the following text:

gitdir: ../Dropbox/myRepo.git

Note: This setup will use a repository that is probably marked as bare (~/Dropbox/myRepo.git) in a non-bare fashion for operations done under ~/myRepo. You may run into problems.


There's the environment variable GIT_DIR that can point at a .git directory, but you would need to have that set correctly when working in the specific folder.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜