Skip to content

Instantly share code, notes, and snippets.

@warpech
Created November 24, 2017 18:11
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 warpech/faa6bef1647a8b908195c7f267e6d8eb to your computer and use it in GitHub Desktop.
Save warpech/faa6bef1647a8b908195c7f267e6d8eb to your computer and use it in GitHub Desktop.
Commit messages

Commit Messages

Commit messages should say why you made a change, not what you changed.

A good commit message has the following:

  • explanation of the problem
  • explanation of the solution
  • reference to the relevant GitHub issue

The reference to the GitHub issue can be made as a URL or in a short form: #issue (e.g. #12). If you refer to an issue from another repo, use org/repo#issue (e.g. StarcounterAps/Launchpad#12). GitHub recognizes this pattern and shows a cross-reference.

This is a bad commit message:

bugfix

To write a good commit message that doesn't miss any of the above points you can use the following template. It splits the message into two parts: the problem and the solution. The problem description is in the headline, followed by the explanation why you are making this change. The solution part can be really short because the diff itself is the solution.

Problem: Some elements do not display starting from starcounter-include 3.0.0

This is because they have a slot attribute but there is no respective slot
element in the declarative Shadow DOM (https://github.com/Starcounter/RebelsLounge/issues/152)

Solution: Add missing slot elements to declarative shadow DOM

With such a commit messages, the description of your Pull Request can almost be empty!

Changing the message after committing

If you have not yet pushed your commits, you can still edit the commit messages.

To edit the commit message of the last commit, you can simply change it using git commit --amend. Sourcetree and other Git GUIs also give an option to amend a previous commit.

To edit commit messages of any commit you can use Git interactive rebase: https://git-scm.com/book/id/v2/Git-Tools-Rewriting-History

Never change commits that have been pushed!

More info

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