Committing is one of the most important operations in Git. It allows you to save your changes to the local repository and build a clear history of your work.
A commit in Git records the current state of staged files. It includes the changes along with a message explaining what and why the change was made.
// Commit staged changes with a short message
git commit -m "Your commit message"
// Opens default editor for a detailed commit message
git commit
// Modify the last commit or add missing changes
git commit --amend
// View commit history of the current branch
git log
// Show changes introduced by a specific commit
git show <commit-hash>
// Undo last commit but keep changes staged
git reset --soft HEAD~1
// Completely discard last commit and changes
git reset --hard HEAD~1
? Edit File → ➕ git add → ? git commit → ? History Updated
git addgit log