How to push changes after rename branch on Bitbucket?

自古美人都是妖i 提交于 2021-02-19 09:23:51

问题


The problem is that I started working on branch called DDH-112 and I pushed it to the repository but then I changed name of this branch by using git branch -m <newname> because the previous one was wrong. Now I can't push changes to the new branch. It says:

    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

After doing git push origin feature/DDH-129-implement-paddings I get error:

! [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 doesn't help at all. I would like to have the Difference after pushing to the new-name branch. Is it possible to push these changes to this branch?


回答1:


First, the command should be:

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

Second, the error message feature/DDH-129-implement-paddings -> feature/DDH-129-implement-paddings (non-fast-forward) makes sense only if you rename your branch with a name of a remote branch already existing, with existing commits.

git pull will help, provided 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


来源:https://stackoverflow.com/questions/52584650/how-to-push-changes-after-rename-branch-on-bitbucket

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!