Skip to content

Instantly share code, notes, and snippets.

@ctavan
Last active February 18, 2021 02:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ctavan/33516e6a8589ee6ae105c8c44e705f3a to your computer and use it in GitHub Desktop.
Save ctavan/33516e6a8589ee6ae105c8c44e705f3a to your computer and use it in GitHub Desktop.
Git & Github

Git & Github

  • Consider using these useful git shortcuts.
  • Repositories:
    • All developers clone the repos from the github organization, never create forks into your private accounts.
  • Branches:
    • Understand git rebase.
    • Development is done in branches.
    • Name branches starting with the JIRA issue followed by an all-lowercase dash-separated descriptive name, e.g: ID-7-shoping-cart-prototype
    • Always rebase onto origin/master before merging into master, we want to get a clean master history which looks like this: branches
    • Merges into master can only be done through github pull requests.
  • Pull Requests
    • Pull requests can be created at any time (even if the branches are not 100% done yet).
    • Pull requests must be reviewed, we use the Github review feature.
    • Once you are happy with the state of your pull request, request a review by assigning an appropriate reviewer.
  • Commits:
    • Commit early and commit often.
    • Commits must always encapsulate meaningful atomic change sets, this means:
      • Never mix refactorings and feature changes in one commit! (I.e. also never put whitespace-only changes into a feature commit.) Also separate changes on tooling from changes on the actual code.
      • Every commit must pass the test suite.
      • When thinking about the scope of a commit you should be able to answer all of the following questions with "yes":
        • Does this change-set address one single concern?
        • Does this change-set contain either only feature changes or only refactorings (like even whitespace-only changes) but not both?
        • Can this change-set safely and reasonably be reverted in the future?
        • Does this change-set pass the test suite?
      • Never commit dead (e.g. uncommented) code: Remove it! You can bring it back through git!
      • Write good commit messages. Here is the guide about writing good commit messages. We follow everything which is described in that guide!
    • Oh shit, git! http://ohshitgit.com/

Useful Config

Please make sure to set the correct @company.com email address!

There are a few useful git config settings that you may want to apply. Whether you want to set them up globally or just for the local repo is up to you (just remove the --global flag if you don't want them to be global):

git config --global commit.gpgsign         true
git config --global push.default           current
git config --global branch.autosetuprebase always
git config --global interactive.singlekey  true
git config --global color.ui               auto
git config --global rebase.autosquash      true
git config --global user.name              "YOUR_NAME"
git config --global user.email             "YOUR_EMAIL"

Guidelines for commit messages

These are good starting points (besides the actual git history) for verbs to use for your commits:

  • Add = Create a capability e.g. feature, test, dependency.
  • Cut = Remove a capability e.g. feature, test, dependency.
  • Fix = Fix an issue e.g. bug, typo, accident, misstatement.
  • Bump = Increase the version of something e.g. dependency.
  • Make = Change the build process, or tooling, or infra.
  • Start = Begin doing something; e.g. create a feature flag.
  • Stop = End doing something; e.g. remove a feature flag.
  • Refactor = A code change that MUST be just a refactoring.
  • Reformat = Refactor of formatting, e.g. omit whitespace.
  • Optimize = Refactor of performance, e.g. speed up code.
  • Document = Refactor of documentation, e.g. help files.
  • Revert me: = This commit contains a temporary solution and should be removed when the condition in the commit message is fulfilled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment