git新建分支時(shí),已經(jīng)推送到遠(yuǎn)程,發(fā)現(xiàn)分支名錯(cuò)了,如何修改分支名,并推送到遠(yuǎn)程?
1、-m 重命名分支,如果 new_branch 名字分支已經(jīng)存在,則需要使用-M強(qiáng)制重命名,否則,使用-m進(jìn)行重命名。
username (20190408_old_branch)
$ git branch -m 20190408_old_branch 20190408_new_branch
2、刪除遠(yuǎn)程分支
username (20190408_new_branch)
$ git push origin :20190408_old_branch
- [deleted] old_branch
3、創(chuàng)建一個(gè)新的遠(yuǎn)程分支
username (20190408_new_branch)
$ git push --set-upstream origin 20190408_new_branch
* [new branch] 20190408_new_branch -> 20190408_new_branch
Branch '20190408_new_branch' set up to track remote branch '20190408_new_branch' from 'origin'.
如果使用idea,執(zhí)行完步驟1和2之后,直接找到剛才修改完名字后的分支,然后推送到遠(yuǎn)程即可。
本文摘自 :https://blog.51cto.com/u