When Git was set up in my Windows system, the root folder selected was /c/Users/anita
. I want to change this location as there are my other files in this location that have nothing to do with my Git projects. I've created a new folder named Git projects
inside c/Users/
. How do I make this new location the .git
directory?
CodePudding user response:
well in theory you should be able to cut and paste those files to the new folder without problems, what i recommend you is: copy
the git related files to the new dir and then update the global enviroment variable
heading to the old folder anita to the new folder you choose
CodePudding user response:
Technically, you could move the .git
folder (that contains all git data) wherever you want (even if it is highly recommended to move it in an empty folder).
A good advice I could give you before moving the folder is to run a git gc
to pack all the git objects and make the copy quicker (especially if the repository history is big).
Your biggest concern will be what to do with the files in the working directory.
To solve this issue, the easier is to commit and after, if needed, stash all the uncommitted remaining changes.
That way, you not necessarily need to copy all the working directory files (and so the copy is quicker) and, if needed, you could recover all the files with the 2 commands:
git reset --hard Head # restore all files
git stash pop # restore uncommitted changes (if you have created a stash)