Git 2 cheatsheet

Git 2: Stash and history

8 common Git 2 tasks.

Stash your work

Set aside uncommitted changes with a label.

git stash push -m "wip: login form"

List stashes

Show saved stashes, newest first, with the label you gave each.

git stash list

Restore the latest stash

Apply the newest stash and remove it from the list.

git stash pop

Copy a commit to this branch

Apply the changes of one commit onto the current branch.

git cherry-pick abc1234

Create an annotated tag

Tag the current commit, for example for a release.

git tag -a v1.0.0 -m "Release 1.0.0"

See who changed each line

Show the commit and author for every line of a file.

git blame file.txt

Find commits that changed a string

List commits whose changes add or remove the given text.

git log -S"functionName" --oneline

Find the commit that broke something

Start a binary search through history. Mark commits with git bisect good and git bisect bad.

git bisect start

Was this page helpful?