Git 无法推送与已删除分支同名的新分支以在远程存储库上创建分支
好吧,标题很混乱,但发生的事情如下: -有一个本地分支及其相应的远程分支 -删除了两个分支 -使用相同的名称重新创建分支,并应用我的更改 -无法推送到远程存储库,因为:Git 无法推送与已删除分支同名的新分支以在远程存储库上创建分支,git,push,bitbucket-server,sourcetree,Git,Push,Bitbucket Server,Sourcetree,好吧,标题很混乱,但发生的事情如下: -有一个本地分支及其相应的远程分支 -删除了两个分支 -使用相同的名称重新创建分支,并应用我的更改 -无法推送到远程存储库,因为: 'Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before
'Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details."
实际上,您没有删除远程分支,而是删除了本地分支(
git branch-d
),可能还删除了对远程分支的本地引用(git branch-d-r
)
要删除远程分支,您需要推送
对远程的空引用:git push remote\u NAME:remote\u branch\u NAME
。冒号前的空格是空引用,告诉REMOTE\u NAME
删除分支REMOTE\u branch\u NAME
现在,如果您认为您已经删除了远程分支,并且您的目的只是删除它,然后向上推送您的新分支,那么您可以节省一个步骤,只需执行强制推送:
git push-f
,这将具有相同的效果。您使用了哪些命令来执行“删除两个分支”步骤?