Skip to content

Instantly share code, notes, and snippets.

@darrentorpey
Last active December 29, 2015 00:09
Show Gist options
  • Save darrentorpey/7583842 to your computer and use it in GitHub Desktop.
Save darrentorpey/7583842 to your computer and use it in GitHub Desktop.
Git tips and tricks

Let's say we have a feature branch:

git checkout -b feature/9999-awesome-things

We can compare this branch's history with another history:

# This will show all changes we've added "since" the tip of master
git log feature/9999-awesome-things..

# Equivalent to the above:
git log feature/9999-awesome-things..HEAD

I use this one all the time:

git log master..

Other forms of that:

# Shows you the line-by-line changes, broken down by commit
git log -p master..

# Shows you just the files that were changed with the +/- counts of # lines changed per file
git log --stat master..

Undo the last commit but keep the changes staged:

git reset --soft HEAD^

I most often use it to make a branch (of my branch) with my current changes but then undo them in the original branch

# in rue-storemanager/ on feature/9999-awesome-things
git checkout -b feature/9999_alt
git add .
git commit -m "Went down a path that I'm backburnering"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment