Logo

dev-resources.site

for different kinds of informations.

How to commit

Published at
11/9/2024
Categories
github
commit
Author
waradu
Categories
2 categories in total
github
open
commit
open
Author
6 person written this
waradu
open
How to commit

go to prefix list directly

Why Even Bother?

Open one of your old repositories and type git log in the terminal. Chances are, you have no idea what you meant by update four months ago.

And no, commit messages like changes, a, or pls just work are not only unhelpful to you but also annoying for your teammates. Clear and informative commit messages make a big difference, especially in collaborative projects.

Use the imperative mood in subject lines (e.g., add german language). It should sound like you are giving an order or request.
added german language would be wrong.

Here are the 5 key points:

  • Write clear and good commit messages that are easy to read.
  • Use prefixes like 'feat:' or 'fix:' at the start of your commit messages.
  • Do not put a period (dot) at the end of your commit message.
  • Keep commit messages short, not more than 50 characters.
  • Use a commit body if needed.

What are commit prefixes?

In short, they make your commits look pretty (if you use refined github) and gives you a better overview ✨.

Imagine a commit message like this: fixed typo. This brings up questions: Where was the typo fixed? Will it break the API?

To make things clearer, use prefixes. In our example, the typo was in the dog images API, changing the query parameter from ?naem=<NAME> to ?name=<NAME>. This is a breaking change because old code using the wrong parameter will stop working.

A good commit prefix for this change could be: fix(api/dogs)!: query param typo.

Lets break it down:

a man breaking it down

Jokes aside:

fix: what is the type of the commit.
(api/dogs): where was the change (optional).
!: is it a breaking change.
query param typo: the actual commit message

In general this is how your commits should be structured:

<type>[optional scope]: <description>

[optional body]

[optional footer(s)]
Enter fullscreen mode Exit fullscreen mode

So here are some example:

feat(lang): add german language
feat(auth): add OAuth support
docs(readme): add installation instructions

This is how it looks on github:

fix: test
fix: test

fix(this): test
fix(this): test

Tipp

Use emojis (if you want that) fix(emoji): :rocket: emojis.
You could also install vscode-conventional-commits to easly make good commit messages.
vscode




All commit prefixes

  • fix: Bug fix
  • feat: a new feature or enhancement
  • chore: updating dependencies or setting up build tools etc
  • ci: change to CI like GitHub Actions
  • refactor: code refactoring without adding new features or fixing bugs
  • docs: documentation-only changes (README etc)
  • style: changes related to formatting such as code style adjustments, and whitespace changes (not css changes)
  • perf: performance improvements without changing existing functionality
  • test: unit tests etc
  • revert: revert a commit

How they look on github (with refined github):

commit prefixes

commit Article's
30 articles in total
Favicon
Why I Built commit-ai: A Story About Git Security and Team Safety
Favicon
使用 AI 自動生成 Git Commit 訊息
Favicon
# How to write good commit messages
Favicon
Conventional Git Commits With Best Practices.
Favicon
Understanding Git Rebase Merge: Chronological vs Logical Order and Commit History
Favicon
Improving Commit Message Quality in VSCode with Copilot
Favicon
TIL how to see the entire commit column on GitLab using JS
Favicon
Why Going Back in Git Doesn't Have to Be Scary
Favicon
🤖 Use AI to speed up writing commit messages (bonus: custom prompt for improved generation)
Favicon
How to commit
Favicon
Commits Semânticos: Organizando o Caos com Padrões de Mensagens
Favicon
Consequences of for-Git-ting to merge the master into feature branch!
Favicon
Git: Commit Messages
Favicon
Yazılım Projelerinde Düzen ve Verimlilik İçin: Conventional Commits Nedir?
Favicon
Good commit message V/S Bad commit message 🦾
Favicon
วิธี sign commit ด้วย GPG บน GitHub
Favicon
Git Together: Pro Tips for Commits and Branches
Favicon
Commit vs. Rollback: Database Transaction Essentials
Favicon
Sign Git Commits and Authenticate to GitHub with SSH Keys
Favicon
Developers Hate This One Weird Trick To Be Improve Their Craft
Favicon
Conventional Commits
Favicon
Cara memperbaiki commit git yang terlanjur commited
Favicon
Multiple SSH id
Favicon
💻 Semantic Commits
Favicon
Client side Git hooks 101
Favicon
How to write GIT commit messages
Favicon
The Power of Conventional Commits ✨✨
Favicon
What I've Learned About Git from Senior Colleagues (Part 2 - thoughful commit)
Favicon
GitHub Commits Color Scheme: Lets commit to commit.
Favicon
How do I make a Git commit in the past?

Featured ones: