I created a repo on Github and cloned it on my local PC using the SSH path which was like:-
[email protected]:user-name/orig_repo.git
That is exactly the URL path that can be seen in the config file of the .git folder in my cloned directory. Then I renamed the Remote Repo, which changed the SSH URL based on the new name:-
[email protected]:user-name/new_repo.git
Since git doesn't care about the name of the local directory as long as the path to which you push is defined properly, I renamed my local directory to the same name of the new repo as new_repo, which is just for sake of my convenience and not a necessity.
What is of more importance is that the path to which it should push has changed ideally, but I still see the original SSH path in my config file, which is:-
[email protected]:user-name/orig_repo.git
But despite the older path, I can push all changes and it reflects in the remote repo properly. I am not sure how this mismatch between the SSH paths is handled. Does git redirect the changes automatically to the new path?
I am using VS Code for running the Git commands, in case it has any effect.
CodePudding user response:
According to GitHub's documentation on renaming repos, when you rename a repo, the old name will redirect everything to the new name, so that any old sandboxes (like yours) and other stuff will keep working.
If you think about it, it's a rather essential feature for GitHub and other hosting services: otherwise, renaming a repo would break a lot of things!
It is recommended that you update your remote, but it's not required, and you can take the time you need to update all the references you might have to it.
The old names will work forever, as long as you don't create a new repo under that old name.