3

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, e.g., /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

Community
  • 1
  • 1
xpt
  • 20,363
  • 37
  • 127
  • 216
  • 2
    http://stackoverflow.com/questions/505467/can-i-store-the-git-folder-outside-the-files-i-want-tracked might help. – DCoder Mar 10 '13 at 15:44
  • @DCoder, thanks! That's exactly what I'm looking for. Please answer isntead so that I can vote it up. thanks! – xpt Mar 10 '13 at 16:11
  • One thing: git's compression over time winds up vastly, somewhat disconcertingly, nearly-magically better than `rar`'s, add up the combined size of your rar backups and compare that with the size of your git repo after you've told it you care (`git repack -Ad; du -sh .git`) which contains all the same data. Host a clone on github or drop an archive on dropbox or google docs or wherever, any of those are safer and more convenient than the backups you're doing now. – jthill Mar 10 '13 at 18:01
  • Thanks @jthill. my person projects was just an example. There are more of my text files that I don't care of their history much. I'm just using git as a mean for off-site backup, just as you suggested. – xpt Mar 10 '13 at 18:12

1 Answers1

3

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?.

I.e., 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. 

Community
  • 1
  • 1
xpt
  • 20,363
  • 37
  • 127
  • 216