Git修改分支名称

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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值