Skip to content

Commiting to Git

Chloe edited this page Apr 29, 2024 · 16 revisions
  • Try to make smaller, but more frequent commits throughout the day, as it's easier to fix and review

  • Add a descriptive message of what kind of changes were made, and why they were neccessary

  • Use git rebase to have linear history

  • Use prefixes in commit messages

    • When ADDING a new function

      ADD: < what has been added >
      
    • When FIXING an error

      FIX: Bug < [what bug] > [description]
      
    • When REMOVING code, files

      DEL: < what has been removed >
      
    • When UPDATING something

      UPD: < what has been updated >
      
  • Some tips about writing helpful commit messages:

    • Separate the title from the body with a blank line
    • Subject line <= 50 characters + imperative mood
    • Use the body to explain what and why vs. how.
    • Body <= 72 characters + why and how
  • Committing not fully-functional additions is possible if all tests pass and nothing breaks because of it.

  • Every commit should be logically connected to one another, if it contains the word and, split it into multiple commits

  • Use the git add -p command to prepare and verify the contents of the commit before finalizing it

    • git diff --cached to review
  • Avoid force push unless really neccessary

Clone this wiki locally