Your daily Git workflow

Create a commit

Record one coherent staged change with a short message that explains its purpose.

8 minute lesson

~~~

A commit records the current staging area. Unstaged and untracked changes stay outside it.

Before committing, inspect the snapshot:

git status
git diff --staged

Then create the commit:

git commit -m "Add project instructions"

A commit stores a project snapshot, parent commit, author, committer, timestamps, and message. Git gives it an object ID based on that content.

Your current branch reference moves from the parent to the new commit. HEAD still points to the same branch.

Verify the result:

git status
git log -1 --stat

If git status still shows changes, they were not in the staged snapshot. This is not an error. It means your working tree contains more work.

Keep each commit focused. It should be easy to explain and safe to review.

Exercise: stage one of two modified files and commit it. Confirm that the other file remains modified after the branch moves to the new commit.

Lesson completed

Take this course offline

Get every free book, course edition, and software download.

Get the download library →