See also: git dotfiles

The best tip is to learn your tools. Git is a beast of a tool, and if you don't spend some time trying to learn it, you will inevitably waste your own time because you didn't know the best way to do something.

Git commit message guidelines

Write good commit messages. Show some craftsmanship and have some pride in your work.

This blog post explains git commit message best practices in detail: https://chris.beams.io/posts/git-commit/

Copying the summary:

The seven rules of a great Git commit message

Keep in mind: This has all been said before.

  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

Sending a repository to someone without a git server

  1. Create a bundle:

    git bundle create repo.bundle --all
  2. Send the bundle to the recipient

  3. Recipient clones the bundle

    git clone repo.bundle

Resetting the commit date of unpushed commits to now

This is destructive, so understand how to get back to your current state before trying!

  1. git rebase -i and set all the commits to edit
  2. while [[ -e .git/rebase-merge ]]; do git commit --amend --date=now --no-edit && git rebase --continue; done

git add -p and untracked files

  • git add -p doesn't work with untracked files
  • Use git add --intent-to-add; an empty version of the file will be staged so git add -p works