Information Technology Reference
In-Depth Information
$ git rm --cached -- [filename]
$ git reset -- [filename]
4-2. Staging and committing a modified
file
Problem
You want to modify and commit a file that was already stored in the repository. To be-
come familiar with how this operation is performed you need to use the $ git status and
$ git status -s
commands before and after every other command.
Solution
Start a new repository with:
$ cd git-recipes
$ git init 04-02
$ cd 04-02
$ git simple-commit modified
Right now the repository is clean and the working directory contains one file named
modified.txt
. The file was created and committed by the
$ git simple-
commit
alias defined in Recipe 3-11.
Now, follow the procedure:
1. Modify
modified.txt
file with
$ echo Some other text >
modified.txt
2. Check the status of the repository with the
$ git status
command.
The output:
# On branch master
# Changes not staged for commit:
#
(use "git add <file>..." to update what will