Feedback

© 2026 SEO Lebedev · All rights reserved.

Commit

A commit is the act of saving changes in a version control system (e.g., Git). Each commit captures the current state of the project’s files — code, documentation, configurations — and adds them to the change history.

Simply put, a commit is a snapshot of the project that allows you to roll back to a previous state or analyze who changed what and when.

What is a Commit

A commit is an action by which a developer saves changes to a local repository. Each commit is accompanied by a message (commit message) that briefly describes what was done — for example, added a new feature, fixed a bug, or updated documentation.

Example: “Added registration form” or “Fixed button display issue on mobile devices.”

What a Commit Looks Like in Git

Each commit has a unique identifier (SHA-1 hash), author, date, and message. Example console output:

text

commit 7a3b4c9d1ef2a4f6b0e4e93b9c8f3e0c56df7d9a

Author: Ivan Petrov <ivan.petrov@example.com>

Date:   Mon Nov 4 10:25:18 2025 +0300

 

Added authorization module and updated login logic

This hash allows precise tracking of who, when, and what changes were made to the project.

How to Make a Commit

The Git commit process typically involves three steps:

  1. Stage files (add to the staging area):
    git add .
    Or selectively: git add src/login.js
  2. Create a commit with a description of the changes:
    git commit -m “Added login form validation”
  3. (Optional) Push the commit to the remote repository:
    git push origin main

Commit Structure

FieldDescription
HashUnique commit identifier
AuthorDeveloper’s name and email
DateTime of commit creation
MessageBrief description of changes
Changed FilesList of files affected by the commit

Example of Multiple Commits

text

* 9a17b23 – Added ‘Buy’ button on product card

* 8b13e54 – Fixed cart display error

* 5c24d87 – Added Header component

* 1a91f12 – Project initialization

Each commit forms a chain that builds the project’s history. You can move between states and revert changes if necessary.

Types of Commits

TypeExample MessagePurpose
featfeat: added category filternew feature
fixfix: fixed authorization errorbug fix
refactorrefactor: optimized API codecode structure improvement
docsdocs: updated documentationdocumentation changes
stylestyle: formatting fixesformatting, no logic changes
testtest: added unit testsadding or updating tests
chorechore: updated dependenciesmaintenance changes (configs, build)

Such conventions are described in the Conventional Commits standard — they help automate releases and changelog generation.

Commit Best Practices

  • Write short and clear messages. A good message is under 50 characters, in the imperative mood:
    “Add form validation”, “Fix filter error”.
  • Make commits logically cohesive. Each commit should solve one task — easier to review and revert.
  • Do not commit temporary or unnecessary files. Add them to .gitignore.
  • Check code before committing. Use git diff or git status to ensure all necessary changes are included.
  • Add a description in the commit body if there are many changes:
    git commit -m “Added Google OAuth” -m “Added OAuth2, updated routing, fixed tests”

Undoing and Amending Commits

CommandAction
git commit –amendamend the last commit (message or files)
git reset HEAD~1undo the last commit, keeping changes in the code
git revert <hash>create a new commit that undoes changes from a previous one
git logview commit history

Important: Be careful when amending commits already pushed to the server — it can cause conflicts for other developers.

Commits and Pull Requests

Commits are the foundation of a Pull Request (PR). When a developer creates a PR, they are essentially proposing to merge their commits into the main branch. High-quality, atomic commits with clear messages help reviewers quickly understand the changes and simplify the review process.

Example Workflow

bash

git checkout -b feature/add-search

# … work on code …

git add .

git commit -m “feat: added site search”

git push origin feature/add-search

# Create a Pull Request on GitHub

After the PR is approved, the commit becomes part of the main branch (main).

Conclusion

A commit is a fundamental element of a project’s history that records changes and allows you to manage code evolution. Well-formatted commits make a project transparent, enable quick bug detection, and help track the evolution of functionality.

Back

Discuss the project

Fill out the form and we will give you a free consultation within a business day.

This field is required

This field is required

Fill in Telegram or WhatsApp

Fill in Telegram or WhatsApp

This field is required

By clicking the button, you agree to “Privacy Policy”.