git checkout -b 'feature-a'
- git commit -m 'working on feature a'
- git commit -m 'working on feature a'
---
- git commit -m 'working on feature b'
- git commit -m 'working on feature b'
- git commit -m 'working on feature b'
---
git checkout master
---
crap just realized I commited on the wrong branch!
# get my commits on the right branch:
git checkout -b 'feature-b'
git cherry-pick sha1 for feature-b commit
git cherry-pick sha2 for feature-b commit
git cherry-pick sha3 for feature-b commit
# remove my commits from the wrong branch:
git checkout 'feature-a'
git revert sha1 for feature-b commit
git revert sha2 for feature-b commit
git revert sha3 for feature-b commit
git push upstream feature-a
git push upstream feature-b
Created
June 29, 2017 17:54
-
-
Save drmmr763/478a70bd44766159f974d74a6edd42cc to your computer and use it in GitHub Desktop.
fix commits when you commit on the wrong branch
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment