1.修改本地分支名称
git branch -m beforeBranchName afterBranchName
2.删除远程分支
git push origin :beforeBranchName
3.将改名后的本地分支推送到远程,并将本地分支与之关联
git push --set-upstream origin afterBranchName
Demo:
D:\Codes2021\code>git branch -m feat_old feat_new
D:\Codes2021\code>git push origin :feat_old
warning: ----------------- SECURITY WARNING ----------------
warning: | TLS certificate verification has been disabled! |
warning: ---------------------------------------------------
warning: HTTPS connections may not be secure. See https://aka.ms/gcmcore-tlsverify for more information.
warning: ----------------- SECURITY WARNING ----------------
warning: | TLS certificate verification has been disabled! |
warning: ---------------------------------------------------
warning: HTTPS connections may not be secure. See https://aka.ms/gcmcore-tlsverify for more information.
remote: fatal: bad object 0000000000000000000000000000000000000000
remote: successfully
To http://gitee.com/product/code.git
- [deleted] feat_old
D:\Codes2021\code>git push --set-upstream origin feat_new
warning: ----------------- SECURITY WARNING ----------------
warning: | TLS certificate verification has been disabled! |
warning: ---------------------------------------------------
warning: HTTPS connections may not be secure. See https://aka.ms/gcmcore-tlsverify for more information.
warning: ----------------- SECURITY WARNING ----------------
warning: | TLS certificate verification has been disabled! |
warning: ---------------------------------------------------
warning: HTTPS connections may not be secure. See https://aka.ms/gcmcore-tlsverify for more information.
Enumerating objects: 129, done.
Counting objects: 100% (122/122), done.
Delta compression using up to 8 threads
Compressing objects: 100% (66/66), done.
Writing objects: 100% (91/91), 12.55 KiB | 494.00 KiB/s, done.
Total 91 (delta 45), reused 0 (delta 0), pack-reused 0
remote: +++++++++++++++++++++++++++++++++++++++++++++++
remote: oldsha: 0000000000000000000000000000000000000000
remote: newsha: 87441c90b50dfcd94e3fbdc5e029cf94b013e7a3
remote: refname: refs/heads/feat_new
remote: +++++++++++++++++++++++++++++++++++++++++++++++
remote: skip
remote:
remote: To create a merge request for feat_new, visit:
remote: http://gitee.com/product/code/merge_requests/new?merge_request%5Bsource_branch%5D=feat_new
remote:
To http://gitee.com/product/code.git
* [new branch] feat_new -> feat_new
Branch 'feat_new' set up to track remote branch 'feat_new' from 'origin'.
D:\Codes2021\code>