本地 branch 重命名 foo => bar

1. 本地重命名,切到分支 foo

git branch -m bar  

或者直接重命名

git branch -m foo bar  

2. 如果分支已经在远端,查看远端 origin

git remote show origin      Remote branches:      foo    tracked      master tracked    Local branch configured for 'git pull':      master merges with remote master    Local refs configured for 'git push':      foo    pushes to foo    (up to date)      master pushes to master (up to date)  

这就需要把本地分支 bar push 上去,把 foo 分支删掉

git push origin :foo bar   - [deleted]         foo   * [new branch]      bar -> bar  

最后在本地的 bar 分支下把 upstream 设置好

git push origin -u bar  Branch bar set up to track remote branch bar from origin.  

查看远端 origin

git remote show origin      Remote branches:      bar    tracked      master tracked    Local branches configured for 'git pull':      bar    merges with remote bar      master merges with remote master    Local refs configured for 'git push':      bar    pushes to bar    (up to date)      master pushes to master (up to date)  

原文出处:jpuyy -> http://jpuyy.com/2017/09/git-%E5%88%86%E6%94%AF%E9%87%8D%E5%91%BD%E5%90%8D.html

本站所发布的一切资源仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如果侵犯你的利益,请发送邮箱到 [email protected],我们会很快的为您处理。