Skip to content

Latest commit

 

History

History
15 lines (11 loc) · 480 Bytes

move_commits.md

File metadata and controls

15 lines (11 loc) · 480 Bytes

Move recent commits from one branch to another

The situation: I just happily coded and three commits in I realise I am still on master / develop instead of the feature branch I want to be.

The solution:

git checkout -b newbranch HEAD~3
git branch --set-upstream-to=oldbranch
git cherry-pick ..oldbranch
git branch --force oldbranch oldbranch~3
git branch --unset-upstream

for a detailed discussion see this SO answer