git-commit-log

Table of Contents

1 Commit    slide

Making history

1.1 Messages

1.1.1 Bad examples    slide

quick fix
Fix bug
Minor UI changes
temp save
make a logic code correctly
update payment screen

1.1.2 Bad examples    slide

committing this change by ABC

=> this information is useless

another fix for #abc

=> And #abc is a long ticket with ~30 comments

fix error in translation file

=> "fix translation file containing wrongly-escaped unicode characters"

change code for ...

=> please actually briefly describe the changes

hack image search while Anh is away

=> not even sure how to think about this

Temporal commit, save XYZ's current work XYZ

=> split it into coherent commits with decriptive messages, by asking XYZ

1.1.3 Bad examples    slide

commit missing files

=> rewrite history to include them in the proper commits

Rollback if exception happens

=> nice try, but not good enough

Update data schema - refactor backend code to add new timesheet entry - display tickets fields in timesheet

=> don't do multiple things in one commit

1.1.4 What is the purpose of commit messages?    slide

Who will read them? A lot of people:

  • Code reviewers
  • Deployer
  • Other team members
  • Future team members
  • A-year-later you
  • Customers

Think of them when you write the commit message

1.1.5 Structure    slide

summary line + explaining paragraphs

fix memory leaks in questionnaire builders

- Release subviews on creating new ones
- Unbind event handlers on releasing a view
clean up organization.customization_options migrations

- Stop using string interpolation.
- Use store.execute instead of building raw cursor from raw connection.
- Stop depending on models.customization_options.customization_options.

Don't do this, use --author

NTA: add translation for close cases

Don't use -m flag. Use an external editor to edit the message, or

# Multi-line message, enter Ctrl-D when done
git commit -F -

2 Blame    slide

Quickly figure out who wrote a piece of code to ask for explanation

git blame

3 Log    slide

Reviewing history

3.1 Format    slide

Short hash + message

git log --pretty=oneline --abbrev-commit

Detailed, showing changes

git log -p

3.2 Filtering    slide

3.2.1 By range    slide

Find out what changes a branch contains

# In b not in a
git log --pretty=oneline --abbrev-commit a..b
# In master not here
git log --pretty=oneline --abbrev-commit ..master
# In here not master
git log --pretty=oneline --abbrev-commit master..

3.2.2 By time    slide

Review a period of work

git log --pretty=oneline --abbrev-commit --since='1 month ago'
git log --pretty=oneline --abbrev-commit --since='2014-01-01'
git log --pretty=oneline --abbrev-commit --until='2 weeks ago'

3.2.3 By author    slide

View a person's work

git log --pretty=oneline --abbrev-commit --author=Anh

3.2.4 By path    slide

Show only changes to a file (or a directory), only in commits changing it

# Viewing dependency changes over time
git log -p --relative=requirements.txt -- requirements.txt

3.2.5 Search    slide

In commit messages

git log --pretty=oneline --abbrev-commit --grep='push.*notification'

In diffs

git log --pretty=oneline --abbrev-commit -GUserNotificationToken

In actual additions/removals

git log --pretty=oneline --abbrev-commit -SUserNotificationToken

3.2.6 By commit types    slide

View only merged features (e.g. combining with range)

git log --pretty=oneline --abbrev-commit --merges

View only actual code changes

git log --pretty=oneline --abbrev-commit --no-merges

Date: 2014-03-13T10:27-0400

Author:

Org version 7.9.3f with Emacs version 24

Validate XHTML 1.0