Suggest an editImprove this articleRefine the answer for “What is git commit used for?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)`git commit` is used to **save staged changes (the staging area) into the repository's history**. A commit is a fixed point in the project's history with a description of what and why was changed. **Key point:** git commit records only what has been added via git add.Shown above the full answer for quick recall.Answer (EN)Image`git commit` is used to **save staged changes (the staging area) into the repository's history**. A commit is a fixed point in the project's history with a description of *what and why* was changed. ## What `git commit` does - **Creates a snapshot of the project's state** - Saves a **commit message** - Generates a **unique hash** - Adds an entry to the **Git history** Important: `git commit` records **only what has been added via** `git add`. --- ## Basic usage ```bash git commit -m "Add user authentication" ``` --- ## Typical workflow ```bash git status # check changes git add . # stage changes git commit -m "Initial commit" ``` --- ## Useful variants ### Commit with the editor open ```bash git commit ``` ### Add changes and commit at once ```bash git commit -am "Fix bug" ``` Works **only for tracked files** ### Amend the last commit ```bash git commit --amend ``` --- ## What is stored in a commit - the list of changes - author and date - the message - a reference to the previous commit --- ## Frequent mistakes - Making meaningless commits: `fix`, `update` - Large "everything at once" commits - Forgetting `git add` before `git commit` --- ## Short version for an interview > `git commit` **saves staged changes into the repository's history, creating a logical fixation point with a description of the changes.**For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.