Information Technology Reference
In-Depth Information
4-4. Staging and committing a removed
file
Problem
Your repository is in a clean state and contains a committed file—
deleted.txt
.
You want to remove the file from the working directory and then commit this opera-
tion.
Solution
Start the repository with:
$ cd git-recipes
$ git init 04-04
$ cd 04-04
$ git simple-commit deleted
Right now the repository is clean and the working directory contains the file
de-
leted.txt
.
Follow the procedure:
1. Remove the
deleted.txt
file with
$ git rm deleted.txt
2. Check the contents of the working directory with $ ls. The file
de-
leted.txt
was removed.
3. Check the status of the repository with the
$ git status
command.
The output:
# On branch master
# Changes to be committed:
#
(use "git reset HEAD <file>..." to unstage)
#
#
deleted:
deleted.txt
#