return 0
return 0

Reputation: 4366

Git did not push correctly after rewriting history

My repo is pretty linear

c1-->c2-->c3

I made a mistake at c2, so I want to go back and fix it, I used

git rebase -i c2

I made the changes to c2, then

git add <whatever-files-changes>
git commit --amend --no-edit
git rebase --continue

Lastly, I did a force push

git push origin <mybranch> -f

I am expecting the following on my remote branch which I just pushed to:

c1-->c2+change-->c3

However, my remote branch now looks like:

c1-->c2-->c3+change

What did I do wrong in the process?

Upvotes: 1

Views: 38

Answers (1)

David Fernandez
David Fernandez

Reputation: 585

With git rebase -i c2 you change your history from c2 onwards, using c2 as the base and actually not changing it, so your changes appear in c3. If you want to change c2 try rebasing using c1 as the new base.

Upvotes: 2

Related Questions