Michal
Michal

Reputation: 51

How to push changes after rename branch on Bitbucket?

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 '[email protected]: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?

Upvotes: 1

Views: 652

Answers (1)

VonC
VonC

Reputation: 1324268

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

Upvotes: 2

Related Questions