Git Commit
Part of the Version Control section of Coddy's Terminal journey — lesson 11 of 58.
Once changes are staged, you save them to the repository with git commit. Every commit needs a short message that describes what changed.
git commit -m "Add welcome message"The -m flag (short for message) lets you write the message inline. Without it, Git would open an editor and wait for you to type one.
Good commit messages are short, specific, and written in the imperative tense, like commands you are giving to the codebase:
Fix login redirect bugAdd dark mode toggleUpdate README with install steps
After committing, git status reports a clean working tree, and the staged changes are now part of the repository's permanent history.
Challenge
EasyThe folder contains readme.md. Initialize the repo, set the local user name to Coddy Learner and email to learner@coddy.tech, stage the file, and create a commit with the message Initial commit.
End by running git status to confirm the working tree is clean.
Cheat sheet
Save staged changes to the repository with git commit. The -m flag lets you write the message inline:
git commit -m "Add welcome message"Good commit messages are short, specific, and written in the imperative tense:
Fix login redirect bugAdd dark mode toggleUpdate README with install steps
After committing, git status will report a clean working tree.
Try it yourself
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Version Control
2Getting Started
Initialize A RepositoryThe .git FolderConfigure Your IdentityGit StatusRecap - First Repo8Merging
What Is A MergeFast-Forward MergeThree-Way MergeMerge ConflictsResolve A ConflictRecap - Merge Master11Feature Branch Project
Project OverviewInitialize Main3Tracking Changes
The Staging AreaGit AddGit CommitModifying A Tracked FileGit LogRecap - First Commits6Recipe Site Project
Project OverviewInitialize And Ignore