如何重命名git遥控器?

时间:2015-11-21 06:54:35

标签: git

我目前有一个名为heroku的git遥控器,我想将其重命名为production

$ git remote -v
heroku  https://git.heroku.com/example.git (fetch)
heroku  https://git.heroku.com/example.git (push)

3 个答案:

答案 0 :(得分:3)

$ git remote rename <old-name> <new-name>

所以,对于这个例子:

$ git remote rename heroku production

这里有用的文档:https://help.github.com/articles/renaming-a-remote/

答案 1 :(得分:1)

请注意,在Git 2.11之前,git remote rename可能会尝试重命名不存在的遥控器!

Git 2.12(2017年第一季度)修正了问题:commit e459b07commit af5bacfJohannes Schindelin (dscho)(2017年1月19日)。 Junio C Hamano -- gitster --于2017年1月31日commit fe575f0合并)

  

remote rename:更仔细地确定是否配置了遥控器

     

~/.gitconfig中定义的遥控器进行预期调整(例如&#34; remote.origin.prune&#34;设置为true,即使有可能或   可能实际上不是&#34; origin&#34;在特定的Git中定义的远程   存储库),&#34; git remote rename&#34;和其他命令曲解   并表现得好像这样一个不存在的遥控器确实存在。

答案 2 :(得分:-1)

当您在答案中链接并说出自己时,您只需键入

即可

git remote rename heroku production

请参阅页面底部:https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes

相关问题