git commit
Records changes to the repository with a descriptive message.
Syntax
git commit [-m <message>] [-a] [--amend]
Options
- -m <message>: Specifies the commit message inline
- -a / --all: Automatically stages all modified and deleted files before committing
- --amend: Replaces the tip of the current branch with a new commit
- --no-edit: Uses the previous commit message when amending
- -s / --signoff: Adds a "Signed-off-by" trailer
- --allow-empty: Allows creating a commit with no changes
Example
git commit -m "feat: add user authentication" git commit -am "fix: correct typo" git commit --amend
Tip
Use --amend to fix the last commit message or add forgotten files.