Misc

Commit Messages

Your commit message should adhere to the following:

  • be no more than 50 characters
  • give a descriptive summary of the work accomplished
  • begin with a present tense verb
  • use sentence case

Examples:

Remove unused attributes
Refactor widgets
Update models and db initialization

If your commit fits one of the following categories, add the appropriate prefix.

  • [FIX]: Fixes a bug
  • [CHANGE]: Changes existing behavior or external API
  • [ENH]: Enhances existing behavior
  • [NEW]: Adds new behavior
  • [CVE]: Patches a security vulnerability

Examples:

[FIX] Set default cache timeout
[CHANGE] Update college data model
[ENH] Optimize data fetching
[NEW] Make number of months configurable
[CVE] Patches elliptic CVE-2020-13822

If your commit fixes an existing issue, add the suffix (closes <ISSUE_NUMBER>).

Example:

[ENH] Standardize number format (closes #10)

Commit Frequency

You should be committing your code and pushing to GitHub often so that your changes are always available for others to see. Even if the commits don't have completed code, still commit them. You should strive to have GitHub up-to-date with your local branch at all times. Once you are ready to merge your code into the master branch, rebase your commits into more logical groups. For example:

  1. All commits that fixed an issue should be grouped into one commit.
  2. Other code changes that are not related to an issue should be grouped into their specific commit tasks.

When to Rebase

There are several times that you should consider rebasing in Git.

  1. Periodically to the master branch to make sure your code doesn't break the new changes to the master branch.
  2. When you make a change that a reviewer requested in a PR.
  3. Any other time that makes sense (you'll learn this over time)

How to Rebase

Rebasing is necessary whenever history needs to be changed. This can be for changing commit messages or for changing the order and contents of commits. For example, if you want to change commit messages follow these steps:

  1. Run git rebase -i master
  2. Change the pick field to edit next to the commit you intend to change
  3. Save the file
  4. Run git rebase --continue
  5. This will reopen the rebase file where you can change the commit text and exit to save

Similarly, you can edit the contents of the files themselves when under edit mode. After step 2 above, the local file system will reflec the changes of the selected commit. Here you can change the files using a text editor and then recommit them like so:

  1. Run git rebase -i master
  2. Change the pick field to edit
  3. Make changes to the file system
  4. Run git status to see edited files
  5. Run git add . followed by git commit --ammend
  6. Complete the rebase using git rebase --continue

This will effectively change the edits included in that specific commit.

On the other hand, if you want to erase a commit entirely you can simply comment out the commits you wish to erase using # and then continue the rebase. This will edit the commit history to erase any commits you erase.

.gitignore File

  • don't commit cache folders and files (add them to .gitignore)