I had a local branch which was branched off master quite some time ago, on which there were several commits. I wanted to get this local branch up to date with master so I did
git co my_branch
git rebase master
expecting this to replay the commits in my_branch on top of master. However, it seems to have instead merged the commits in my_branch into master and then brought my_branch forward to the same place as master, i.e. I’ve gone from this:
A -- B -- C -- D master, origin/master
\
E -- F my_branch
to this:
A -- B -- E -- F -- C -- D master, origin/master, my_branch
when I was expecting this:
A -- B -- C -- D master
\
E' -- F' my_branch
My question is not so much why it did this, but whether I can put things back to where they were originally, since presumably the inserted commits will be problematic when interacting with the remote repository (to which subsequent commits have been pushed).
Edit
It turns out that I had already merged in the branch. So, the rebase had nothing to do and just left the my_branch pointer in same place as master.
As mentioned in my edit above, it turns out I had already merged in my_branch. So, the branch commits were already part of master, and the rebase had nothing to do after moving the my_branch pointer to the last commit in master.