Renaming a Git repository is straightforward because Git identifies a repository by its folder name, not an internal “project title.” When you rename the directory that contains your .git folder, the repository is effectively renamed.
This guide explains how to:
- Rename any local Git project
- Verify that Git history remains intact
- Connect the renamed project to a remote service (GitHub, GitLab, Bitbucket, etc.)
1. Rename the Local Repository Folder
Step 1 — Close All Apps
Close any editors, terminals, or tools currently accessing the project folder.
Step 2 — Rename the Folder
From your operating system’s terminal:
# Navigate to the parent directory
cd <path-to-parent-directory>
# Rename the project folder
Rename-Item "<old-folder-name>" "<new-folder-name>"
Or on macOS/Linux:
cd <path-to-parent-directory>
mv "<old-folder-name>" "<new-folder-name>"
After this operation, your repository now uses the new name.
2. Verify Git Still Works
Navigate into the renamed folder:
cd <new-folder-name>
git status
git log --oneline -5
You will see:
- Your commit history unchanged
- Your branches intact
- A clean working directory (unless there were changes before renaming)
All Git metadata remains inside the .git directory, so nothing is lost.
3. Optionally Add or Update a Remote Repository
If you want to back up the project or publish it, you can link the renamed local repo to any remote platform (GitHub, GitLab, Bitbucket, Azure DevOps, etc.).
Step A — Create a New Remote Repository
On your chosen platform:
- Create a new empty repository (do not initialize it with README if you already have one).
- Copy the remote URL provided (HTTPS or SSH).
Step B — Connect Your Local Repository to the Remote
cd <new-folder-name>
# Add remote
git remote add origin <remote-url>
# Set main branch (optional if already exists)
git branch -M main
# Push to the remote
git push -u origin main
Now your renamed local repository is tracked by the remote service.
4. Summary of the Rename Process
- Close applications using the project folder
- Rename the project folder using your OS rename command
- Reopen the project in your editor
- Git automatically detects the change
- Optionally create and connect to a remote repository
5. Key Notes
- Git does not store an internal “project name.”
- The repository name equals the folder name containing
.git. - Renaming the folder never affects commit history, branches, or files.
- A remote URL can be added, removed, or replaced at any time.