使用Git删除文件需要使用Git rm命令来实现,最后git commit
需要注意的是直接rm命令删除后是不可以的,可以用git status 命令尝试一下,效果如下(创建了test文件,演示了git rm和rm的区别):
19:54:51linux@~/Documents/git/test >> vi test
19:55:07linux@~/Documents/git/test >> ll
total 16
-rw-rw-r--. 1 linux wang 2007 Apr 18 07:02 getZhihuDaily.py
-rw-rw-r--. 1 linux wang 22 Apr 18 07:02 README.md
-rw-rw-r--. 1 linux wang 5 Apr 30 19:55 test
drwxrwxr-x. 7 linux wang 86 Apr 20 06:08 vim-colors-solarized
-rw-rw-r--. 1 linux wang 1233 Apr 30 19:47 vimrc
19:55:09linux@~/Documents/git/test >> git add test
19:55:15linux@~/Documents/git/test >> git commit -m "test"
[master 710da9d] test
1 file changed, 1 insertion(+)
create mode 100644 test
19:55:24linux@~/Documents/git/test >> ls
getZhihuDaily.py README.md test vim-colors-solarized vimrc
19:55:26linux@~/Documents/git/test >> git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
# (use "git push" to publish your local commits)
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# vim-colors-solarized/
nothing added to commit but untracked files present (use "git add" to track)
19:55:35linux@~/Documents/git/test >> rm test
19:56:30linux@~/Documents/git/test >> git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
# (use "git push" to publish your local commits)
#
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: test
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# vim-colors-solarized/
no changes added to commit (use "git add" and/or "git commit -a")
19:56:33linux@~/Documents/git/test >> git rm test
rm 'test'
19:56:41linux@~/Documents/git/test >> git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
# (use "git push" to publish your local commits)
#
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# deleted: test
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# vim-colors-solarized/
19:56:47linux@~/Documents/git/test >> git commit -m"rm test"
[master 2953ea2] rm test
1 file changed, 1 deletion(-)
delete mode 100644 test
19:57:00linux@~/Documents/git/test >> git status
# On branch master
# Your branch is ahead of 'origin/master' by 2 commits.
# (use "git push" to publish your local commits)
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# vim-colors-solarized/
nothing added to commit but untracked files present (use "git add" to track)
相关文章:
8个Git的小技巧:http://www.linuxdiyf.com/linux/11097.html
Git使用入门教程:http://www.linuxdiyf.com/linux/9213.html
Git使用教程图文详解:http://www.linuxdiyf.com/linux/8817.html