Skip to content

Instantly share code, notes, and snippets.

@bsima
Created January 30, 2017 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bsima/a4569ccaa6747038775394be65649b29 to your computer and use it in GitHub Desktop.
Save bsima/a4569ccaa6747038775394be65649b29 to your computer and use it in GitHub Desktop.
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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment