Information Technology Reference
In-Depth Information
$ git commit -a -m "Staging and committing
removed file"
5. Check the status with the
$ git status -s
command. The output is
empty, therefore the repository is clean. The working directory doesn't
contain the
removed.txt
file.
How It Works
You can use standard commands such as
$ rm
to remove files in the working direct-
ory. If you want to stage all removed files you can use the
-a
flag of git commit
$
git commit -am "..."
or one of the following commands:
$ git add -u
$ git add -A
You also can stage only selected files removed with the
$ rm
command; to achieve
the use of the
$ git rm [filename]
command.
To summarize, the following two procedures will have the same effect for
file-
name.txt
:
# first procedure
$ rm filename.txt
$ git commit -am "..."
# second procedure
$ rm filename.txt
$ git rm filename.txt
$ git commit -m "..."
They differ in one aspect: the first procedure will commit all tracked files (staged
and unstaged); the second will commit only staged files.
Both procedures are shown in
Figure 4-5
.