How to separate/decouple git repository into a different location
My request may look strange but it'd make more sense after I explain why I'm doing it.
So I have my person projects under /path/to/myprojects
. Underneath maybe C, Perl, Shell, Tcl, etc. Now I want to put those project groups (C, Perl, etc) under git, but in different location, eg, /path/to/mygits/
.
The reason that I want to do this is that, traditionally I backup my /path/to/myprojects to other locations by rar them first. Since they are all text based, rar them up will yield excellent compression ratio. Now I want to keep the same practice, even I've introduced git. Thus I need to keep the binary git repository out of the way of my text base folder into a separate binary base folder.
All my findings on stackoverflow indicate impossible, or I "have to use submodules which can be quite painful": Git: Different Working Directory and Repository location, git repository with folders in different locations, Add Separate Directories/Projects/Files to Git Repository
However, there is one answer that says it is possible to decouple the git working directory and git repository directory: how do I change the location of a Git repository but it says something about git reset --hard
which I want to know the details.
Also Using GIT_DIR
seems to be another solution.
Anybody can help?
Thanks
Alright, enough waiting, let me answer my own question. As DCoder has pointed out, the answer is at Can I store the .git folder outside the files I want tracked?.
Ie, there are many git based solutions listed there, all needs some extra git configuration. You might have to do them if under Windows. However, under Linux, symlinking the .git directory to somewhere else is the easiest and cleanest solution.
链接地址: http://www.djcxy.com/p/18882.html