Reputation: 11
This is the Situation in my git repository: I have two branches "dev" and "fix" and need to move the three most recent commits on the fix branch to the dev branch. The head is on the last commit on the dev branch (E). So i need to go from this:
dev A
\
fix B - C - D - E
^HEAD
to this:
dev A - C - D - E
\ ^HEAD
fix B
I'd appreciate any help on how to accomplish this with git commands (it's an offline repository)
Upvotes: 1
Views: 37
Reputation: 30156
it's simple
git checkout dev
git cherry-pick fix~3..fix # apply the last 3 revisions from fix
git checkout fix
git reset --hard HEAD~3 # set fix 3 revisions behind
You are rewriting history, in case it's not obvious, it's more like:
dev A - C' - D' - E'
\ ^HEAD
fix B
Upvotes: 2