Rename a Git repository in your project
TFS 2018
Visual Studio 2019 | Visual Studio 2022
You can rename a Git repository in a project from your web browser. After you rename the repo, each member of your team should take a few steps to re-enable their dev machines to connect to the repo on the server.
Prerequisites
- To rename a repository, you must have Rename Repository permissions on your Git repo.
Rename the repository
-
- From the web portal, open the project administration page for your project and select Version Control.
Select the repo you want to rename under Git repositories on the left and select .... Select Rename repository... from the menu.
Note
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.
Update the Git remotes on your dev machines
Git uses remote references to fetch and push changes between your local copy of a repository and the remote version that is stored on the server. After a Git repository or project has been renamed, you should update your remote references. Update your references to that the remote repository URL contains the project and the repository name.
Each member of your team must update their local Git repos to continue connecting from their dev machines to the repo in the project. The instructions below show how to update the remotes for the Fabrikam Mobile repo that was renamed to Fabrikam.
Get the new URL for the repo
Select Clone in the upper-right corner of the Code window and copy the Clone URL.
Update your remote in Visual Studio
To update your remote:
In the Git menu from the menu bar, select Manage Remotes.
In the Options dialog, select the remote to edit, then select Edit.
Replace the fetch and push remote references with the URL that you copied from the remote repo.
Select Save and then OK to close the Options dialog.
Visual Studio 2019 version 16.8 and later versions provides a Git version control experience while maintaining the Team Explorer Git user interface. To use Team Explorer, uncheck Tools > Options > Preview Features > New Git user experience from the menu bar. You can exercise Git features from either interface interchangeably.
To update your remote from Visual Studio Team Explorer:
Connect to the repo.
Open the project settings.
Open the repo settings.
Edit the fetch and push remote references and paste the URL that you copied from the remote repo.
Q&A
Q: Can I rename my repo again? Can I reuse an old repo name?
A: Yes