【问题标题】:Cannot push new branch with same name as a deleted branch to create a branch on the remote repository无法推送与已删除分支同名的新分支以在远程存储库上创建分支
【发布时间】:2015-12-31 18:50:36
【问题描述】:

好吧,标题很混乱,但发生了什么事:

-有一个本地分支及其对应的远程分支

-删除两个分支

-重新创建具有相同名称的分支,并应用我的更改

-无法推送到远程存储库,因为:

'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 push bitbucket-server sourcetree


【解决方案1】:

您实际上并没有删除远程分支,而是删除了本地分支 (git branch -d),可能还有对远程分支的本地引用 (git branch -d -r)。

要删除远程分支,您需要 push 对远程的空引用:git push REMOTE_NAME :REMOTE_BRANCH_NAME。冒号前的空格是空引用,告诉REMOTE_NAME 删除分支REMOTE_BRANCH_NAME

现在,如果您认为您已经删除了远程分支,而您的意图只是删除它,然后向上推送您的新分支,您可以节省一步,只需执行强制推送:git push -f 将具有相同的效果。

【讨论】:

    猜你喜欢
    • 2020-05-22
    • 2014-02-04
    • 1970-01-01
    • 2021-04-15
    • 1970-01-01
    • 2011-02-23
    • 2015-09-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多