1

I'm working on the the feature branch called auth, which was branched out from master branch:

C1 (master) \ C2-C3 (auth) 

After I've made C3 commit, I pushed the auth branch to remote for backup. Then master branch is updated on remote and the history looks like this:

C1-C4 (master) \ C2-C3 (auth) 

I'm rebasing auth branch to updated master branch and the history now looks like this:

C1-C4 (master) \ C2-C3 (auth) 

Then I make more changes on auth branch, make C5 commit and push auth branch to remote and the push is rejected with the message that there are updates on remote that I don't have locally. But I know that no one else pushed to the auth branch on remote. So why is this behavior?

This article provides just a simple explanation for such behavior:

Beware though: if the rebased branch had been pushed to a remote (for backup purposes, for instance), you’ll need to force the next push of it with the -f option, as you just replaced its commit history with a fresh one.`

1 Answer 1

2

The rebase has changed the history of the auth branch.

That is why you need a forced push, which is OK only if you are the only one to work on this branch.
If not, it would be best to:

As in:

C1-----C4 (master) \ \ C2-C3--M--C5 (auth) 
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, VonC! I think to better understand your answer I'd need to know how git knows that there changes on remote that are not here, i.e. why git reports exactly this error. What's the topic to investigate or resource to read about that?
@Maximus it is not really "changes that are not there". It is simply because the auth SHA1s on GitHub differ from the auth SHA1 you are trying to push (as illustrated in marklodato.github.io/visual-git-guide/index-en.html#rebase)
@Maximus git rebase changes the commits SHA1 by changing it's parent commit; this makes git consider the local commits to be different from the remote one.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.