Skip to content

Latest commit

 

History

History
124 lines (86 loc) · 4.25 KB

README.md

File metadata and controls

124 lines (86 loc) · 4.25 KB
title
Git Good

This is a starting point for mastering git, a sisyphean task no doubt. Git is a complex software, nobody is expected to master all of it, so if you have a useful tip, please share!

The git manual pages are actually very good. Start with man git and maybe check out man gittutorial. Don't be shy about using man git-<subcommand> when you don't know how to do something. If you're curious about different ways to use git in your daily workflow, check out man gitworkflows.

Table of Contents

Guidelines

  • Separate commits into small, logical changes. Avoid large diffs as much as possible. link

  • In a commit message, the first line is a brief what, the rest is a succint why. link

  • In commit messages, limit the first line to 50 characters, wrap the rest to 80 characters. link

Grokking Git

Rebasing: the most important concept

I once read an interview with Linus where he said that every git command is basically a different take on rebase. So, if you want to get good at git quick, learn about rebasing - the rest will follow.

Branching

Tools

Git isn't perfect. These tools make it easier to work with:

Commit Messages

Original article: How to Write a Git Commit Message

Git was originally used over email: someone would make a change to some software, create a .patch file, and email it to the maintainer. In the email, the author of the patch would add an appropriate subject with a brief line about what the patch does, and then in the body they would explain why the patch is a good idea.

Commit messages retain this structure: the first line is a brief what, the rest is a succint why.

Seven Rules to Good Commit Messages

I guess they're really more like guidelines...

  1. Separate subject from body with a blank line
  2. Limit the subject line to 50 characters
  3. Capitalize the subject line
  4. Do not end the subject line with a period
  5. Use the imperative mood in the subject line
  6. Wrap the body at 72 characters
  7. Use the body to explain what and why vs. how

Automate Good Commit Messages with .gitmessage

Originally created by David Winterbottom, this is a quick hack to make you more likely to write helpful commit messages.

Save the following as ~/.gitmessage:

# If applied, this commit will...


# Why was this change made?


# Any references to tickets, articles, etc?

Then, add the following to ~/.gitconfig:

[commit]
  template = ~/.gitmessage

Other References & Tutorials