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

commit [June 22, 2011, 2:06 a.m.]


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

Commiting

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.

 

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)