📁 Git
Extract Accidental Commits

Updated at 2018-03-09 07:22

How to fix that you commit to the local master by accident?

git checkout master
git branch my-stuff         # copy everything in master to my-stuff

git reset --hard HEAD~3     # remove 3 commits from master
git reset --hard 1234abcd   # or remove everything _after_ this commit

git chekout my-stuff        # has master + the removed commits