Git#

Commit messages#

Follow the format:

type(scope): Capitalized, <72 characters, no period

A longer description of paragraph text, as needed.

- Bullet points and other Markdown are okay, too

#123

Most commits are made in pull requests, such that it’s easy to find the discussion on GitHub. As such, it’s not necessary to provide a long narrative, if it exists in a pull request or linked issue.

Reference:

Feature branches#

In general, repositories should have only a default branch and pull request branches. If the repository is a fork, it may have a main branch for the source branch and an opencontracting (or open_contracting) branch for the fork branch.

To start work on an issue, create a branch, following this naming convention:

{issue-number}-{brief-description}

This makes it easy to know what the changes in a branch are about.

Note

If no issue exists for the work you want to do, please create an issue first.

Configuration#

We recommend using:

# Create a "main" branch (instead of a "master" branch) when creating repositories.
git config --global init.defaultBranch main

# Use --set-upstream (-u) with `git push` by default.
git config --global push.autoSetupRemote true

# Ignore the commits in this file (if it exists), like code formatting or file renaming.
git config --global blame.ignoreRevsFile .git-blame-ignore-revs

# See demo at https://ductile.systems/zdiff3/
git config --global merge.conflictstyle zdiff3

# Display dates as 2001-02-03 04:05:06 instead of Sat Feb 3 04:05:06 2001.
git config --global log.date iso

# Detect moved lines better.
git config --global diff.algorithm histogram
# Use different colors for moved lines (minimum 20 characters).
git config --global diff.colorMoved default
# Allow indentation changes when detecting moved lines.
git config --global diff.colorMovedWS allow-indentation-change

# Delete branches/tags locally that were deleted remotely (e.g. after merge on GitHub).
git config --global fetch.prune true
git config --global fetch.pruneTags true

You might also like delta (installed separately).

If you sign commits, tell Git about your signing key, for example:

git config --global commit.gpgsign true
git config --global --unset gpg.program
git config --global user.signingkey ~/.ssh/id_rsa.pub
git config --global gpg.format ssh
git config --global --unset gpg.format
git config --global user.signingkey 3AA5C34371567BD2
git config --global gpg.program $(which gpg)

Excluded paths#

Add the following to your ~/.config/git/ignore file:

.DS_Store
*.pyc

In general, use the repository’s .gitignore file, to not rely on each user having configured global exclusions.

Common excluded paths include:

*.mo
*.swp
*~
/*.egg-info
/.coverage
/.ve
/build
/dist
/docs/_build
/htmlcov
__pycache__
node_modules