I own both the upstream bare repo and the working directory.
In my working directory, I created a local branch (mybranch
), made changes, then pushed it to origin/mybranch
to create a remote-tracking branch.
I later made local changes to master and pushed those upstream.
Then I rebased my local branch on local master.
When I tried to push my rebased local branch, I get this message:
% git push origin mybranch
To /path/to/upstream.git
! [rejected] mybranch -> mybranch (non-fast-forward)
error: failed to push some refs to '/path/to/upstream.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.
The current output of my git log alias:
* 3fa023e - (4 days ago) message 3 - author (HEAD -> mybranch)
* 5ab9691 - (8 days ago) message 2 - author
* e4f148f - (8 days ago) message 1 - author
* 6bc545a - (24 hours ago) other message 3 - author (origin/master, origin/HEAD, master)
* 2a97604 - (3 days ago) other message 2 - author
* f75211a - (4 days ago) other message 1 - author
| * 8cb0b67 - (4 days ago) message 3 - author (origin/mybranch)
| * f86182c - (8 days ago) message 2 - author
| * 661e7a1 - (8 days ago) message 1 - author
|/
* 80a92e1 - (9 days ago) old message -author
The hashes are different for origin/mybranch
and local mybranch
but you can see that the commits are the same by the identical messages.
Two questions:
- Where did I go wrong? Was my original local rebase incorrect?
- How do I fix this going forward? I want the state of upstream/mybranch to reflect what I have locally. I did attempt the recommendation in the error message (
git pull
on my local branch), but this triggered a merge, which didn’t seem right, so I aborted and reverted.
I own both the upstream and local repos so I can do whatever needs to be done, including creating backups of both before experimenting.