Last Updated: February 25, 2016
·
1.767K
· craigmarvelley

Rebasing relative to a commit

When rebasing a series of git commits, you may know that if you supply the sha of a commit, the rebase operation will start at the commit that comes immediately after. If you want to include the commit specified by the hash, or any other commit relative to that one, you can use the tilde operator, so

git rebase -i 5524dc9~1

would start an interactive rebase with the pointer moved back one commit,

git rebase -i 5524dc9~2

would move the pointer back two commits, and so on.

1 Response
Add your response

That's cool! I've always done HEAD~number before where the number is how many commits back from head I want to go so this will save some effort I think :)

over 1 year ago ·