其他开发人员在更新他的本地存储库后,在src目录中找到一个module.py文件。查看提交消息后,了解到module.py文件是由maxsu添加的。
bjpowernode@ubuntu:~/git/sample$ pwd
/home/bjpowernode/git/sample
bjpowernode@ubuntu:~/git/sample$ ls
README.md src
bjpowernode@ubuntu:~/git/sample$ ls src/
main.py
bjpowernode@ubuntu:~/git/sample$ git pull
Updating 186df84..6bdbf82
Fast-forward
src/{main.py => module.py} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename src/{main.py => module.py} (100%)
bjpowernode@ubuntu:~/git/sample$ ls src/
module.py
bjpowernode@ubuntu:~/git/sample$ git log
commit 6bdbf8219c60d8da9ad352c23628600faaefbe13
Author: maxsu
Date: Mon Jul 10 20:34:28 2017 +0800
renamed main.py to module.py
......
现在,假设要对上面的项目中代码结构进行重构,代码文件:module.py 已经不再使用了,要将它删除,那么应该怎么做?请参考以下命令:
bjpowernode@ubuntu:~/git/sample$ pwd
/home/bjpowernode/git/sample
bjpowernode@ubuntu:~/git/sample$ ls
README.md src
bjpowernode@ubuntu:~/git/sample$ git rm src/module.py
rm 'src/module.py'
bjpowernode@ubuntu:~/git/sample$ git commit -a -m "remove/delete module.py"
[master 7d8162d] remove/delete module.py
1 file changed, 26 deletions(-)
delete mode 100644 src/module.py
bjpowernode@ubuntu:~/git/sample$
验证删除结果
在另外一台电脑上,执行以下命令更新当前工作区,查看 sample/src 目录中的文件是否还存在?
$ git pull