Information Technology Reference
In-Depth Information
You can restore the
old-file.txt
with:
$ git reset -- [old-filename]
$ git checkout -- [old-filename]
The
new-file.txt
can be removed with:
$ rm new-file.txt
4-8. Committing a file renamed with the
standard mv command
Problem
Your repository is clean and contains one file named
old-name.txt
. You want to
rename and commit the change. You prefer to perform the renaming with the standard
$ mv
command.
Solution
Start the repository with:
$ cd git-recipes
$ git init 04-08
$ cd 04-08
$ git simple-commit old-name
The repository is clean and the working directory contains one file—
old-
name.txt
.
Follow this procedure:
1. Rename the file with
$ mv old-name.txt new-name.txt
2. Check the status of the repository with the
$ git status
command.
The output: