To rename a repo on git that is cloned to your folder (project) on your local drive (with the same name of course) while preserving the connection between them follow these steps.
1- Rename your remote repo on GitHub/GitLab: Go to your repo settings → Rename it to
2- Rename the local folder on your machine directly on the folder name or in bash: mv
3- Now, in a local terminal go into the renamed local folder and update Git’s remote URL using: cd <path to the folder's new name> git remote set-url origin <new_repo_url>
Note: don't forget to replace <new_repo_url> with the new repo URL from GitHub/GitLab, which includes the updated name.
4- Finally, you might want to verify the connection is h: git remote -v
If it shows the correct new URL, we're all set!