MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
Recording Snapshots: git commit and Semantic Commit Messages0%
Study Materials
Git & GitHub BasicsProgress 0%
1.1What is Version Control? (Local, Centralized vs Distributed VCS)1.2Why Git? History, Architecture & Core Benefits1.3The Three Trees: Working Directory, Staging Area & Git Repository1.4Installing Git and Initial Configuration (git config user.name / email)
2.1Initializing a Repository (git init and .git Directory Anatomy)2.2Tracking Changes: git status and Staging with git add2.3Recording Snapshots: git commit and Semantic Commit Messages
HomeTutorialsGit & GitHub BasicsRecording Snapshots: git commit and Semantic Commit Messages
Inspecting Commit History with git log and Formatting Flags

Recording Snapshots: git commit and Semantic Commit Messages

Beginner12 min read•Updated: 2026-09-15•By Er. Sumit Kumar (MSK Institute)
Study MaterialsCheatsheet

Once you have staged your desired changes, the next step is to record them permanently in the repository object database using git commit. A commit represents a cryptographic snapshot of your project at a specific instant in time.


1. How git commit Works

When you commit, Git:

  1. 1
    Takes the files currently in the Staging Area (Index).
  2. 2
    Creates a tree object representing the directory structure.
  3. 3
    Packages author metadata, committer timestamp, commit message, and pointers to parent commits into a Commit Object.
  4. 4
    Computes the 40-character SHA-1 hash for this commit.
  5. 5
    Advances the current branch pointer (and HEAD) to point to the new commit.
1Commit Object Hierarchy:
2+-------------------------------------------------------------+
3| Commit Hash: 7b3f81e... |
4| Author: Sumit Sharma <sumit@mskinstitute.com> |
5| Date: Mon Sep 15 10:30:00 2026 +0530 |
6| Parent: 4a2c91d... |
7| Message: feat(auth): add JWT token expiration check |
8| Tree: 9f1e82b... --> [ Blobs & sub-trees for all files ] |
9+-------------------------------------------------------------+

2. Basic Commit Commands

A. Committing with an Inline Message (-m)

The most common everyday command:

1git commit -m "Add responsive navigation bar for mobile screens"

B. Committing via Text Editor (Multi-line Commits)

Omitting the -m flag opens your configured editor (VS Code, Nano, Vim) to write a detailed multi-line message:

1git commit

C. The Shortcut: Stage Tracked Files & Commit (-am)

If files are already tracked (previously committed) and you simply edited them:

1# Automatically stages all tracked modified files AND commits in one shot
2git commit -am "fix: correct typo in checkout pricing calculation"
Important Warning
[!CAUTION] -a only stages modified tracked files! It will not stage newly created (untracked) files.

3. Amending the Last Commit (git commit --amend)

Have you ever committed, only to realize 5 seconds later that you forgot to include one file, or made a spelling mistake in your commit message? Instead of creating a messy follow-up commit like "oops forgot this file", you can amend the most recent commit:

1# 1. Stage the forgotten file
2git add forgotten_file.css
3 
4# 2. Amend the previous commit without changing the message
5git commit --amend --no-edit
6 
7# Or amend both code and update the commit message:
8git commit --amend -m "feat: complete navbar styling with mobile drawer"
Important Warning
[!WARNING] Only amend commits that exist purely on your local machine! Never amend or rewrite commits that have already been pushed to a shared remote branch on GitHub.

4. Professional Semantic Commit Conventions (Conventional Commits)

Top engineering teams (and open-source projects) adhere to the Conventional Commits specification:

1<type>[optional scope]: <description>
2 
3[optional body]
4 
5[optional footer(s)]

Common Standard Types:

TypePurposeExample
featA brand new feature for the userfeat(auth): support Google OAuth login
fixA bug fixfix(cart): prevent negative discount calculation
docsDocumentation changes onlydocs(readme): update deployment instructions
styleFormatting, missing semi-colons, whitespacestyle(css): reorder media queries with prettier
refactorCode restructure that neither fixes bugs nor adds featuresrefactor(db): extract connection pool singleton
perfCode change that improves performanceperf(search): debounce live search input by 300ms
testAdding or correcting unit/integration teststest(auth): add unit test for expired JWT token
choreBuild system, dependency updates, toolingchore(deps): bump tailwindcss to v4.0

Interactive Quiz• Knowledge Check

Practice Quiz

Question 1
What is a Git commit?
Question 2
What does the command git commit -m "message" do?
Question 3
What is the limitation of using git commit -am "message"?
Question 4
When is it safe to use git commit --amend?
Question 5
In Conventional Commits, which type is appropriate for a commit that updates third-party npm or pip dependencies?
Next Lesson

Inspecting Commit History with git log and Formatting Flags

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
Tracking Changes: git status and Staging with git addInspecting Commit History with git log and Formatting Flags

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

Mentor-Led Practical Training

Master Git & GitHub Basics with Hands-On Projects

Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext