notes-computer-programming-git

Git commit message conventions

 The first line:

There is a blank line in between the first line and the rest.

The rest is word-wrapped to 72 characters (EXCEPT for quoted material that has a specific line format). The rest explains what and why, but not how.

Sources: [1] [2] [3] [4]

Git Workflow

Mostly https://speakerdeck.com/ewoodh2o/release-management-git-workflow

(todo summarize that here)

In addition:

DEVELOP and MASTER

Categorize Git repos into 'personal' and 'common'. Either may be 'public' in the sense that the public can see their contents, and either may or may not be dictatorially controlled by one person.

Each project has at least one common repo (call it 'origin'), and at least two branches within this repo, DEVELOP and MASTER (or, perhaps some projects have DEVELOP and MASTER in two different repos; in this case you may want to call them DEVELOP and PRODUCTION instead).

DEVELOP: Nothing gets into develop unless (a) it appears not to break the build, and (b) it is definitely going into the next release. Ideally, at any time it should be possible to deploy from DEVELOP; however there's some room for error here. If something is merged to DEVELOP and it breaks the build, under most circumstances the merge should be reverted, rather than trying to make a series of hotfixes to DEVELOP or MASTER.

MASTER: MASTER is ALWAYS ready to be deployed/released. It should be OK for an automated script to pull from MASTER and deploy that at any time, without asking a human if that's a good idea. There may be some QA between DEVELOP and MASTER. Any crazy production hotfixes are committed to MASTER.

Some projects have other common repos, and many projects have personal repos.

When to rebase

DO rebase your personal repo off of DEVELOP frequently, and especially just before submitting a merge/pull request, eg using 'git pull --rebase'

DO use rebase to clean up history in your personal repos before requesting/permitting a merge. You are free to rebase anything in a personal repo at any time, with the following exception:

DON'T rebase any commits for which you have given permission to merge into a common repo, or anything that you have given permission to be merged into someone else's personal repo, unless you have an agreement with the owner of the other repo to make sure it doesn't ever get into a common repo. (A merge or pull request is implicitly giving permission)

DON'T rebase anything in common repos. Merge upstream, don't rebase off of it.

Don't merge from personal repos without permission

DON'T merge anything from a PERSONAL repo into a COMMON repo without the permission of the personal repo owner (because if they rebase after you merge, there is a problem). (clearly, you CAN merge from any public repo whose license is compatible with yours; it's just not recommended).

DON'T even merge from someone else's personal repo into your own without persmission, unless you plan to make sure the result never gets into a common repo.

Versioning

http://semver.org/

Sources

[5] [6]

todo

toread: https://wiki.openstack.org/wiki/GitCommitMessages

clean up 'misc', below


to test each commit when rebasing: git rebase -x 'make test'

  1. git >= 2.9 only

misc

?: if you are the lowest hierarchical level in a tree of development branches (i.e. a single person's working branch), then always rebase when you pull from higher levels of the hierarchy. If, however, you are not the lowest level (you are someone else's upstream), then merge.

a description of a (non-Git) workflow for developing Chrome: https://medium.com/@aboodman/in-march-2011-i-drafted-an-article-explaining-how-the-team-responsible-for-google-chrome-ships-c479ba623a1b summary of that link:

links

See also [7]