How to rename git root folder?

I just started using git in Vista, with my repository under /path/to/project/git repo .

Now I found that the space in the folder name is a minor annoyance when working in git bash.

Can I just rename the folder to /path/to/project/gitrepo ? Is everything inside git config relative, or is there anything explicitly related to the parent folder?

I tried just making a copy of Windows from the main folder and running git bash, and << 24> the log shows the changes that I previously made. Therefore, I assume that the renaming of the main folder is fine, but I would like to be sure before moving on.

+75
git directory folder rename
Aug 26 '11 at 3:15
source share
4 answers

To slightly modify Greg's answer , yes, everything with a git repo refers to the parent .git directory, but:

(and this probably will not affect you directly, I will give here only some reasons for completeness.):

  • other services running on your computer may refer to the path of the repo itself (Apache, ssh, another repo declaring your repo remote using the full path to the file, the gitolite layer declaring your repos according to a certain path, ...)
  • some operations use the full repo path (such as GIT_INDEX_FILE using filter-branch in the command, see this filter-branch ), so obviously do not rename the root directory when performing a complex operation in your repo.

In addition, the β€œcopy of Windows” (instead of git clone ) will copy everything, including hooks, which may include an absolute path in their script if you edited them and made similar changes.

+49
Aug 26 '11 at 6:07
source share

Yes, it’s safe to rename the folder containing the Git repository. All paths in the Git repository are relative.

+81
Aug 26 '11 at 3:17
source share

Please check comments first ...

In my opinion, it is best to use the git workflow , especially when you are using a git server (remote main repository), which means:

  • synchronize the old directory with your git server ( git pull , git push and finally git status to see if everything is ok)
  • git clone <former directory> <new directory>

(Since I'm also new to GIT, this may not be the complete, correct answer. I had the same question as Mick, and for training purposes I tried to do it in the git spirit :) Thanks for the tip, vonC! Please correct me if necessary :)

+4
Jun 18 '14 at 19:03
source share

Yes, you can change that. your repository is still directed to your git .. just don't delete / edit the name .git fo

0
Jun 10 '19 at 12:44 on
source share



All Articles