DEV Community

Git Commit Guides

The git commit command allows you to save your changes to the local git repository you are working in. Before committing, you meed to git add the changes. Learn more in these guides.

This is a collection of top and trending guides written by the community on subjects related to Git Commit properties. For all things git, check out the git tag! Please contribute more posts like this to help your fellow developer in need.

How to merge a specific commit into another branch

What this does is, "It applies the change introduced by the commit at the tip of the working branch and creates a new commit with this change". The issue I had with that was, I had made a couple of commits and I needed all those commits in the master branch. That's when I found it.


How to move a commit to another branch in git

As long as you haven't pushed your changes up to origin, this is very easy to undo. Let's say we have made a commit a1b2c3d on the branch feature-a, and we haven't yet made a feature-b branch.


Please don't commit .env

Running a quick search on GitHub reveals that there are still a number of people who didn't get the memo. The occasional add .env and remove .env commit titles appear every now and then in the search results. Looking into the content of the commits indeed shows their precious API keys and database passwords. It's honestly funny to see how they revert their changes like how a child becomes guilty of doing something they shouldn't have.


Git commit message convention that you can follow!

A typical git commit message will look like


Git 101 — Step 2: add, stage, commit & push

In the previous post I gave a introduction about Git and how to install it. In this video I show you how you can manage your changes, commit them and eventually push them to Github.


How to Write Useful Commit Messages (My Commit Message Template)

We've all lived the XKCD about git commit messages at some point.


How are you writing a commit message?

I'll write a little bit about a topic that is not related to code, seemingly not that important, but it is quite practical in daily programming. How to write git commit message properly?


How to validate commit message convention using Commitlint and Husky

Here I’ll show How to validate a commit message before doing a commit and make the convention rules.


Patterns for writing better git commit messages

It's an opinionated guide I keep with me to consult every time I catch myself in doubt if I'm writing nice commit messages with context of what I'm delivering.


Run a TypeScript type check in your pre-commit hook using lint-staged + husky

A great way to prevent TypeScript compilation errors from bringing down your CI pipelines is to introduce a type check before you commit your .ts file changes.


Enforce Husky Pre-Commit With ESLint & Prettier In Monorepo

This will create a .husky folder in the root directory with pre-commit file in it. This file would have a single command npm test in it.


How to use emoji in your commit message ⚡ ⚡

Using emojis in your commit messages will be fun (😊) and cool (😎) in the first place.


Oops, I just pushed a git commit to the wrong branch. What now?

The erroneous commit is 65c356c8c


How to go back to a previous commit in git

Have you ever accidentally committed the wrong files to git, but you hadn't pushed your commit up to origin yet and just want to tidy up?


Padronização de commit com (Commitlint, Husky e Commitizen)

A prática de criar commits atômicos consiste em criar um commit para cada modificação no projeto, por exemplo, vamos imaginar que estamos trabalhando em um projeto e fizemos duas ações:


Help! VS Code Source Control is listing every file on my computer! How can I just commit the changes from my current project?

Like many developers, I have a bad habit of getting sucked into the code and forgetting to commit my changes to Github. One day a few months back I was happily coding along, adding new features to my React application. Suddenly remembering that commits are important, I went ahead and clicked the source control tab, prepared to write the mother of all commit messages, and gritted my teeth for the inevitable merge conflicts.


How to write a good commit message

A commit message is a short description of the changes you've made to a file added before committing the changes.


How to setup Git commit hooks for PHP

If a single check fails the error message is displayed and the commit is aborted.


Git commit aborts before I can create a commit message and I use “--wait”

I use Visual Studio Code on my Mac as my text editor and have it set up to open a new window to type my commit message, however when I type 'git commit' in the terminal, it instantaneously displays 'Aborting commit due to empty commit message.'


Making git commit messages useful with Jira, Jenkins and scopes

Writing anything meaningful in the commit messages already makes you an awesome dev and puts you ahead of most. I've seen too many meaningless commit messages and it makes it so hard to track down a problem. Some of the most famous ones I've read were:


Git pre-hook: Setup pre-commit hook for NPM project example

There are various Git pre-hooks that are quite helpful for several essential tasks we want to execute before commit or push or rebase etc. Basically, there are various use cases, like running linting before you commit or running unit tests before push or commit.


Git Workflow: Do you commit to master on your solo projects?

When you are working on a project you know you will be working on solo do you still work out of branches or do you commit to master? Does it depend on the project?


Configuring Prettier and TypeScript Compiler as a Pre-commit Hook

We decided to use git pre-commit hooks to help prevent "broken" commits.


Automatically Format your code on Git Commit using Husky, ESLint, Prettier in 9 minutes

Run the configure-husky script to install Husky and connect it to the pre-commit hook:


Using husky's pre-commit hook with a GUI

Now doing a commit in a GUI should show you the issues with the code when doing a commit:


A Guide to writing Industry Standard Git Commit Message

I choose to describe this as Git commits that can be generally understood across the tech ecosystem. It shouldn’t commit messages that have very complex terms, it should be readable and understood by people that don’t even contribute to the code base.


Git pre-hook: Setup pre-commit hook for Gradle project example

There are various Git pre-hooks that are quite helpful for several essential tasks we want to execute before commit or push or rebase etc. Basically, there are various use cases, like running linting before you commit or running unit tests before push or commit.


What tense do you use in Git Commit messages?

Do you use past or imperative tense in your commit messages?


A cleaner Github workflow: one commit per Pull Pequest

In this guide you'll learn how to keep a cleaner Git history having one commit per Pull Request (hereinafter referred to as "PR").


How to write good commit messages?

The commit command is used to save changes to our local repository after staging in Git. Before saving to our local repository, we need to tell Git which changes you need to save, as you have done lots of changes. A better way to do this, by adding commit messages to tell what changes you have done.


Automatically lint & format your code on commit when using Next.js

In this post, we will be setting up Next.js with Husky and lint-staged to run ESLint and Prettier whenever we commit a file.


How to change the git commit author?

In the case that the commit was pushed remotely we need to run an extra commit.


Tip 4: Git Commit Templates & Conventional Commits

Git commit messages are important. We all know that, yet ... in the heat of the moment, we're prone to this non-sense:


Changing a Git commit Message

If a commit message contains unclear, incorrect, or sensitive information, you can amend it locally and push a new commit with a new message to GitHub. You can also change a commit message to add the missing information.


Auto-generating a commit message

I am tired of writing commit messages which are bigger than the code changes and which could be programmatically and precisely generated. I am writing my own Python script as a pre-commit message hook. Does anyone know of an existing tool or script to do this?


Improving Your Commit Message with the 50/72 Rule

Last week I put up a post about setting up a custom commit message template, and I thought it would be worthwhile to write a followup post about the 50/72 Rule


Drops #02: Como alterar o autor do commit depois do push

A dica de hoje é de como alterar o autor do commit depois de já tê-lo enviado ao seu repositório remoto.


Better Commit Messages

Going through my TL saw the below tweet, I felt attacked a bit. As a one man army on most of my projects, I always do typical one liners, init, update, readme, fix-01, and so on. In this article I will show you how to configure git to launch your template on vscode for better commit messages.


Git Commit Message Template in Terminal and VS Code

Recently I've been trying to write better commit messages. With my ADHD, my motto is always be writing it down, so I was delighted when my coworker told me about git commit message templates.


Spoof a commit on GitHub. From Anyone.

Did you know that anyone can commit as you on GitHub? If you don't believe me, just browse through this repository's forged commits or use our tool to forge a commit for yourself.


Git Commit Message

I managed to write this post long time ago, but just now I found some time to write it. I want to cover the thing that every active developer faces everyday probably multiple times from 1 to 10, 20, 30 times a day. So I will talk about Git commit messages.


Enforcing Git Commit Message Style

I was working on a project that wanted commit messages in the following formats


An automatic interactive pre-commit checklist, in the style of infomercials

What's that, you say? You've become tired of regular old boring paper checklists? Well, my friend, today is your lucky day! You, yes, you, can become the proud owner of a brand-spanking-new automatic interactive pre-commit hook checklist! You're gonna love this! Your life will be so much easier! Just wait until your friends see you.


Adding a basic pre-commit check to a Next.js app

When building a Next.js app, it can be a good idea to add some simple checks for Typescript and ESLint when you commit new code. It can help avoid broken Vercel builds and keep your code neat and functional for other contributors.


My commit message workflow

I totally obsess over commit messages. I often spend minutes staring into space trying to come up with the best way to summarize the changes a commit brings. I religiously follow the seven rules of good commit messages. As you might have guessed, I've spent some time developing a workflow for writing commit messages.


Rewriting latest commit with git amend

In this post, we will cover how to rewrite the latest commit in Git.


How to smartly cleanup your commit history using git reset?

Running git reset --soft <commit-hash> will move the branch to this old commit. And now when you run git status, you will see all the changes you have made since commit-hash in your staging area. You can then create a single commit to update your commit history.


Happy Git Commit coding!