Skip to content

Instantly share code, notes, and snippets.

@yas375
Last active April 12, 2016 05:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yas375/8c992d947242f68c9206487b916c679d to your computer and use it in GitHub Desktop.
Save yas375/8c992d947242f68c9206487b916c679d to your computer and use it in GitHub Desktop.
How to do rebase on a branch which has been force pushed

How to do rebase on a branch which has been force pushed

Looking into your branch:

98a21db Lorem (5 days ago)
3e3fc13 Ipsum
f73a5bb Dolor - This was the latest commit in parent branch when you've started a new one.
a25992b Sit - This is the first commit in your new branch.
42f6c06 Amet (1 hour ago)

Someone force pushes the parent branch and now its commits have new SHAs.

aaaaaa1 Lorem
bbbbbb1 Ipsum
cccccc1 Dolor
dddddd1 And even more commits

You need to rebase your branch on the parent branch with the command:

git rebase --onto parent-branch f73a5bb

f73a5bb - is parent of your first commit. This way git knows that it should take commits in your branch after THIS commit and apply them on top of current parent-branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment