This course will become read-only in the near future. Tell us at if that is a problem.


Once we have made changes to a repository, it is necessary to commit those changes so that the changes are saved in the repository history.

Staging Files

We will make sure that any files that we have edited are added to the repository:

$  git add file_name
$  git status -s
M file_name


The commit command will save new file changes to the repository history. Each commit is accompanied with a message describing the changes. The flag for message is -m.

git commit -m "Added file_name."

You can use the -a flag to automatically add all modified and tracked files.

Also, if you leave off the -m flag, Git will open up a text editor so that you can enter a commit message.

Checking the status again

The status will now reflect that there are no new changes awaiting a commit:

$ git status
# On branch master
nothing to commit (working directory clean)

Further Reading

Git Reference: Commit

Git Manual: Commit


Task Discussion

  • holdenweb   Oct. 13, 2011, 3:21 a.m.

    A little confusing that you shows add with new files in the previous lesson, so the M status in the first example isn't something that the students will have come across. I'd suggest either adding a further modification to the last example, or explaining in this lesson that it means that hte content has been modified.

    Also: "If you leave out the -m flag and the message that follows it ..."

    One final note: these coments take an AGE to process. I hope this is because the site is busy ... because if not it will never get busy - it will be too slow!