Information Technology Reference
In-Depth Information
Right now the repository is clean and the working directory contains one
file— old-name.txt .
Follow this procedure:
1. Rename the file with $ git mv old-name.txt new-name.txt
2. Check the contents of the working directory with the $ ls command.
The working directory now contains a file named new-name.txt . The
file old-name.txt has disappeared.
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)
#
#
renamed:
old-name.txt -> new-name.txt
#
explains that the operation of moving a file was staged.
4. Check the simplified form of status. The output of $ git status -s
will be:
R_ old-name.txt -> new-name.txt
The state is denoted by two characters: the letter R followed by a space.
5. Commit the changes with the $ git commit -m "Staging and
committing moved file" command.
6. Check the status with the $ git status -s command. The output is
empty, therefore the repository is clean.
How It Works
The syntax of $ git mv is given in the following:
Search WWH ::




Custom Search