1

I have many projects and each project has many branches on Git. I want to keep .git folder organized in one directory. This way, I have only one location for every repository while the source files can be somewhere else.

I did a few searches on Google but no luck yet. Is it possible to do that? If so, how to do it?

Anonymous
  • 9,366
  • 22
  • 83
  • 133
  • Quick Search on Google [Can I store the .git folder outside the files I want tracked?][1] [1]:http://stackoverflow.com/questions/505467/can-i-store-the-git-folder-outside-the-files-i-want-tracked – taylorcressy Feb 27 '14 at 10:50
  • I've found that link before asking the question but it's not practical since I have to add additional parameter. I am looking for a solution like setting a windows variable, that way I don't have to keep track by myself. – Anonymous Feb 27 '14 at 10:58

1 Answers1

0

You can use the following variables (man git):

  • GIT_DIR (or --git-dir param) to set the path to the repository.
  • GIT_WORK_TREE (or --work-tree param) to set the path to the working tree.

For example:

GIT_DIR=/path/to/.git GIT_WORK_TREE=/path/to/files git status

Related: Can I store the .git folder outside the files I want tracked?

kenorb
  • 155,785
  • 88
  • 678
  • 743