【问题标题】:How do I rename local branch after remote branch was renamed?远程分支重命名后如何重命名本地分支?
【发布时间】:2022-08-09 16:15:29
【问题描述】:

有人在 Github 上重命名了我已经有一些未推送的提交的分支,现在我无法推送它们,因为该分支不存在。我不想更改新的远程分支名称,我只想适应我的本地分支。只是重命名分支不起作用,因为 git 仍然想推送到相同的旧分支名称。

    标签: git github gitlab bitbucket


    【解决方案1】:

    我从here 发现了解决方案。诀窍很简单,只需在推送之前执行以下几行:

    # Rename the local branch to the new name
    git branch -m <old_name> <new_name>
    
    # Prevent git from using the old name when pushing in the next step.
    # Otherwise, git will use the old upstream name instead of <new_name>.
    git branch --unset-upstream <new_name>
    
    

    我以其他格式重新发布此内容,因为问题不同,并且对某人有用。

    【讨论】:

      猜你喜欢
      • 2015-08-15
      • 2011-10-28
      • 1970-01-01
      • 2011-09-29
      相关资源
      最近更新 更多