git

Reference

Git flow

Configure user

Check your current user config:

git config --list

Update your user config:

git config --global user.name "Thomas A. Anderson"
git config --global user.email "thomas.anderson@metacortex.com"

Writing commit messages

Commit messages should be written in present tense.

<!-- Good -->
Update the navigation

<!-- Bad -->
Updates the navigation
Updated the navigation
Updating the navigation

Snippets

Undo unstaged work

Undo changes that have not been staged or committed to a file:

git checkout -- filename.txt

Undo commits

Undo last unpushed commit and keep changes in working directory:

git reset --soft HEAD^

Undo last unpushed commit and lose changes:

git reset --hard HEAD^

Diffing

# Generate diff and save to file
git diff --name-status [commit1] [commit2] > file.txt

# Example
git diff --name-status b521ddfd8064c622471e0dabc7db2cfcef536713 c300d0553a95c20317e1f35f998d76843ae97b35 > file.txt