GIT

Jose Canahui
1 min readOct 24, 2017

This is a small set of notes I took looking over some best practices for git.

Commits

They should be A.C.I.D.

  • Atomic
  • Consistent
  • Incremental
  • Documented

Stashing

Stashing un-indexed changes: git stash save --keep-index <name>

Popping the last stashed item: git stash pop

Commit Message

Structure should consist of a short summary (max 50 chars) and a longer description.

This client-side hook validates the commit message to make sure it is formatted correctly. It can be installed with wget http://git.io/validate-commit-msg --show-progress --quiet -0 .git/hooks/commit-msg then grant execution rights with chmod a+x .git/hooks/commit-msg.

Trail of Commits

For new features, we can add commits that leave the app in a consistent state with all tests passing. Example commit stages could be refactoring, failing test & ignoring, implementing the feature…

We can re-write history to make sure we leave a good trail of commits. We do this with an interactive rebase.

Rebase

git rebase <branch> -i lets you rebase to a branch and re-write your history.

--

--