Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rename git root folder?

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

I've now found that the space in the folder name is a minor irritation when working in git bash.

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

I've tried just taking a windows copy of the main folder, and run git bash on that, and 'git log' shows the changes I had previously made. So I assume renaming the main folder is OK, but I'd like to be sure before I go any further.

like image 231
Mick O'Hea Avatar asked Aug 26 '11 03:08

Mick O'Hea


People also ask

Can I rename my repository folder?

On GitHub.com, navigate to the main page of the repository. Under your repository name, click Settings. Under the Repository Name heading, type the new name of your repository. Click Rename.

How do I change the root directory in Git bash?

Change Default Directory in Git BashRight-click on Git Bash's shortcut icon and go to the Properties. In the Start in field, paste the path to the desired folder, e.g. D:\WorkDir.

Can I rename folder after Git clone?

The fastest way to change the folder name when cloning a GitHub repository is to simply specify the name you want at the end of the git clone command. Here's a short video showing the entire process: When you're done downloading the repo do cd your-app-name to enter your directory with all the Create React App files.

How do I rename a Git repository?

Select the repo you want to rename under Git repositories on the left and select .... Select Rename repository... from the menu. If the Repositories pane is not expanded, select > to expand it and display the list of repositories. Enter a new repo name in the Repository name field in the dialog, then select Rename.


2 Answers

Yes, it is safe to rename the folder containing a Git repository. All paths inside the Git repository are relative.

like image 73
Greg Hewgill Avatar answered Sep 28 '22 04:09

Greg Hewgill


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

(and this won't probably affect you directly, I only mention those reasons here for completeness' sake.):

  • the path of the repo itself could be referenced by other services running on your computer (Apache, ssh, another repo declaring your repo as a remote, using the full file path, a gitolite layer declaring your repos in a certain path, ...)
  • some operations use the full path of the repo (like the GIT_INDEX_FILE using within a filter-branch command for instance, see this thread), so, obviously, don't rename the root directory while performing a complex operation on your repo.

Plus, a "windows copy" (instead of a git clone), will copy everything including hooks, which may include absolute path in their script if you have edited them and made those kind of modification.

like image 31
VonC Avatar answered Sep 28 '22 02:09

VonC