Let's say I have a topic branch whose entire history I want to rewrite since it was originally created from master for a pull request. For whatever reason, it is not easy or obvious using git log
to determine the commit hash I want to pass to
git rebase -i <commit>
I know I can use git merge-base <branch1> <branch2 || master>
to find the commit that two references can trace their ancestry from and can use that to determine the commit. What I would like to know is if there is a better way to interactively rebase this whole branch (whether master has advanced or not) than using
git rebase -i `git merge-base my_branch master`
EDIT: I do not want to change the parent of the first commit made on this branch so git rebase -i master
would only work in the case where both master has not advanced since the branch was created and the branch was created from the commit master currently points to.
Maybe I'm misunderstanding your question, but I think git rebase -i master
should do what you want. It will figure out the merge base and rebase the entire branch from that point to the current HEAD so that it appears to have been branched from the current tip of master.
Also, if master has not advanced, then rebasing will pretty much be a no-op.