How Do I Rename a Git Remote?
I Currently Have a Git Remote Called Heroku and I'd Like to Rename It to Production. $ Git Remote -v Heroku (Fetch) Heroku (Push) 4 Answers $ Git Remote Rename...
I currently have a git remote called heroku and I'd like to rename it to production.
$ git remote -v
heroku (fetch)
heroku (push)
4 Answers
$ git remote rename <old-name> <new-name>
So, for this example:
$ git remote rename heroku production
Useful docs here:
Be aware that until Git 2.11, git remote rename might try to rename a non-existing remote!
That is fixed in Git 2.12 (Q1 2017): See commit e459b07, commit af5bacf (19 Jan 2017) by Johannes Schindelin (dscho).
(Merged by Junio C Hamano -- gitster -- in commit fe575f0, 31 Jan 2017)
remote rename: more carefully determine whether a remote is configuredWith anticipatory tweaking for remotes defined in
~/.gitconfig(e.g. "remote.origin.prune" set totrue, even though there may or may not actually be "origin" remote defined in a particular Git repository), "git remote rename" and other commands misinterpreted and behaved as if such a non-existing remote actually existed.
With Git 2.26 (Q1 2020), "git remote rename X Y" needs to adjust configuration variables (e.g. branch.<name>.remote) whose value used to be X to Y.
branch.<name>.pushRemote is now also updated.
See commit b3fd6cb (01 Feb 2020), and commit f2a2327, commit 923d4a5, commit ceff1a1, commit 1a83068, commit 88f8576 (27 Jan 2020) by Bert Wesarg (bertwesarg).
(Merged by Junio C Hamano -- gitster -- in commit d0038f4, 25 Feb 2020)