Skip to content

Git notes

Rand McKinney edited this page Nov 10, 2016 · 1 revision

These are just some random notes for git commands that may come in handy.

Throw away local changes

If you've made some local changes, but not yet pushed them; and you just want to start over:

git reset --hard HEAD

Squash commits

When you have a bunch of commits to branch and you want to squash them into one before merging a PR:

Checkout your branch and list all the commits:

git clone https://github.com/strongloop/<repo>.git -b <branch>
cd <repo>
git log

Find the SHA of the last commit before you branched:

git reset --soft ddc29a3655b252296bf0675b28b63dd9e7bbcc45
git status
git commit -m "Comment here"
git push -f