← Lessons/Your First Commit
← Your First Commit

Commit it

Learn

Snapshot it: git commit

git commit -m "message" records everything staged as a permanent snapshot, with your message describing why. A good message is short and specific: "Add README", "Fix login timeout", not "stuff".

git log --oneline shows the history, one commit per line: a short hash (the commit's ID) and its message.

git commit -m "Describe the change"
git log --oneline

Commit the staged file with the message Add README, then run git log --oneline to see your first commit in the history.

Interview prep

The init → add → commit loop is the most basic thing every engineer is expected to know cold.

What's the difference between git add and git commit?

git add stages a change — it moves it into the index (the staging area), the set of changes that will go into the next snapshot. git commit records everything currently staged as a permanent commit in the history. The two-step design lets you choose exactly which changes belong in a commit rather than committing everything at once.

sandbox@opspath: ~
OpsPath sandbox · Debian GNU/Linux 12 · GNU bash 5.2
Your session carries over: files, commits, branches and cd all stick.
Press restart (top right) to go back to this mini lesson's starting point.
Type a command and press Enter. ↑/↓ history · Ctrl+L clear · Ctrl+C cancel line
# ── Step 3 · Commit it ──
# Sign in to run commands — it's free.