Keeping .git folder outside of dropbox
Dropbox tends to have problems with git files. Making duplicates etc. However, I would like it to back up some elements that I may not necessarily include in my git repositories and also track changes that I haven’t yet commit to git.
I have a great solution for this when it’s a brand new git repo (
I change directories to the project folder in dropbox and in a terminal:
git --git-dir=~/git_storage/my.git --work-tree=. init && echo "gitdir: ~/git_storage/my.git" > .git
It works exactly as I would expect. It replaces the
.git folder in the working directory with a text file
.git containing the directory in which the git files are actually stored. All of this – outside of dropbox. Leaving only the
.git text file to be synced.
However, I’d like to know how to have the same setup (.git directory outside of dropbox) for a cloned or, already existing repository.
One Solution collect form web for “Keeping .git folder outside of dropbox”
If the repo already exists in Dropbox (ie, you cannot clone it with the
--separate-git-dir=<git dir> mentioned by charlesreid1), you can:
- move the .git outside of DropBox
GIT-DIRto the new path of the .git
That way, you go on working in your Git repo (whose working tree remains in Dropbox like before), but your git commands will use the .git repo which is now outside Dropbox (even though I had bad experiences before, and use
git bundle instead).