1

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?

Michal
  • 51
  • 3

1 Answers1

2

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
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • When I enter `git branch -u feature/DDH-129-implement-paddings origin/feature/DDH-129-implement-paddings` it says that `fatal: branch 'origin/feature/DDH-129-implement-paddings' does not exist` :// – Michal Oct 01 '18 at 06:45
  • 1
    @Michal Sorry, try `git branch -u origin/feature/DDH-129-implement-paddings feature/DDH-129-implement-paddings`, from https://stackoverflow.com/a/2286030/6309 – VonC Oct 01 '18 at 07:01