Sumant Agnihotri
Sumant Agnihotri

Reputation: 522

How to rebase a particular commit over another commit?

enter image description here

Right now the main branch has the commit order 1,3,4. with 2 being a separate commit from 1. I need the order to be 1, 2, 3, 4. How do I do it? I'm unable to figure out how to use rebase over here. Thanks for the help

Upvotes: 0

Views: 87

Answers (1)

Chris Maes
Chris Maes

Reputation: 37742

You need a simple git rebase:

git checkout sumant # your current branch
git rebase origin/master

NOTES:

  • you can replace origin/master with c0fbd68... it all points to the same commit :)
  • your commit 2 can contain changes that conflict with your commits 3,4,... You'll have to solve these conflicts manually. git does what it can, but cannot resolve all conflicts automatically.

Upvotes: 3

Related Questions