# On branch master
# Changed but not updated:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: foo.txt
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# bar.txt
no changes added to commit (use "git add" and/or "git commit -a")
如果您决定要重命名该文件来记录树的状态,您可以使用以下方法进行更改:
git rm foo.txt
git add bar.txt
然后 git status会告诉你:
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# renamed: foo.txt -> bar.txt
$ ls
a b c d
$ mv d e
$ git status
# On branch master
# Changed but not updated:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: d
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# e
no changes added to commit (use "git add" and/or "git commit -a")
$ git add --all
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# renamed: d -> e
#
will do the necessary modification. By default, it will rename the older file name with the newer file name as shown below,
rkalaiselvan@CHN-LAP-RAVICHA MINGW64 ~/Documents/GitHub/project-euler-solutions/python (development)
$ git status
On branch development
Your branch is up to date with 'origin/development'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
problem_2.py
nothing added to commit but untracked files present (use "git add" to track)
rkalaiselvan@CHN-LAP-RAVICHA MINGW64 ~/Documents/GitHub/project-euler-solutions/python (development)
$ git mv problem_1.py multiples_of_3_and_5.py
rkalaiselvan@CHN-LAP-RAVICHA MINGW64 ~/Documents/GitHub/project-euler-solutions/python (development)
$ git status
On branch development
Your branch is up to date with 'origin/development'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
renamed: problem_1.py -> multiples_of_3_and_5.py
Untracked files:
(use "git add <file>..." to include in what will be committed)
problem_2.py