如何在Bitbucket上重命名分支后推送更改?

时间:2018-10-01 04:41:11

标签: git bitbucket

问题是我开始在名为DDH-112的分支上工作,并将其推送到存储库中,但是后来我使用git branch -m <newname>更改了该分支的名称,因为前一个错误。现在,我无法将更改推送到新分支。它说:

    fatal: The upstream branch of your current branch does not match
the name of your current branch.  To push to the upstream branch
on the remote, use

    git push origin HEAD:DDH-122

    To push to the branch of the same name on the remote, use

    git push origin feature/DDH-129-implement-paddings

完成git push origin feature/DDH-129-implement-paddings后,我得到了错误:

! [rejected] feature/DDH-129-implement-paddings -> feature/DDH-129-implement-paddings (non-fast-forward) error: failed to push some refs to 'git@bitbucket.org:apptension/dontdrivehigh.git' hint: 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 pull根本没有帮助。在推送到新名称分支之后,我希望拥有差异。是否可以将这些更改推送到该分支?

1 个答案:

答案 0 :(得分:1)

首先,命令应为:

git push -u origin feature/DDH-129-implement-paddings 

第二,错误消息feature/DDH-129-implement-paddings -> feature/DDH-129-implement-paddings (non-fast-forward)仅在使用已经存在的具有提交的远程分支的名称重命名分支时才有意义。

git pull将为您提供帮助,the associated remote branch is feature/DDH-129-implement-paddings

git fetch
git branch -u origin/feature/DDH-129-implement-paddings feature/DDH-129-implement-paddings
git pull
# resolve conflicts
git push