- Add issue number followed by colon
:- For GitHub and GitLab issue numbers use square brackets
[#123]: - For Jira issues brackets are not needed
PROJ-123:
- For GitHub and GitLab issue numbers use square brackets
- Use the imperative, present tense: "Change" not "Changed" nor "Changes"
- Do capitalize the first letter
- Do not end the first line with a period
. - Second line must always be empty
- Use a list to describe changes (in case first line is not enough)
- Separate changes that are not related to current ticket:
- Use separate section in a commit message OR
- Use separate commit
Branch names must be all lowercase and follow the pattern
${BRANCH_TYPE}-${ISSUE_NUMBER}-${SHORT_DESCRIPTION}for example fix-123-handle-null-pointer
featureorfeat: when it contains a new feature or code refactoringdocumentationordoc: any documentation changestest: when adding testsfix: for bug fixes
git branch feature-123-some-descriptiongit checkout feature-123-some-description
git status
It does not display new files or directories.
git diffor view specific file(s) or directories
git diff test.ts
git diff test1.ts test2.ts
git diff src/commongit add file1
git add file1 file2 file3
git add src/commonAlways check what is added before commit using git status
git commitor
git commit -m "Fix race condition in test foo"-i means interactive, where commits can be squashed, fixed up or dropped.
git rebase -i maingit push -u origin feature-123-some-descriptionTo override history, for example when squashing commits, always use --force-with-lease it prevents overriding if the remote branch is newer.
git push --force-with-leasegit checkout main
git merge feature-123-some-description
git push