Git 删除操作
Git 删除操作
Tom更新了他的本地存储库,并在src目录中找到了编译后的二进制文件,查看提交消息后,他意识到编译后的二进制文件是由Jerry添加的。
[tom@CentOS src]$ pwd /home/tom/project/src [tom@CentOS src]$ ls Makefile string_operations string_operations.c [tom@CentOS src]$ file string_operations string_operations: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped [tom@CentOS src]$ git log commit 29af9d45947dc044e33d69b9141d8d2dad37cc62 Author: Jerry Mouse <jerry@tutorialspoint.com> Date: Wed Sep 11 10:16:25 2013 +0530 Added compiled binary
VCS仅用于存储源代码,而不是可执行二进制文件。所以,Tom决定从存储库中删除这个文件。为了进一步的操作,他使用了git RM命令。
[tom@CentOS src]$ ls Makefile string_operations string_operations.c [tom@CentOS src]$ git rm string_operations rm 'src/string_operations' [tom@CentOS src]$ git commit -a -m "Removed executable binary" [master 5776472] Removed executable binary 1 files changed, 0 insertions(+), 0 deletions(-) delete mode 100755 src/string_operations
做好注释之后,他推送了他的版本。
[tom@CentOS src]$ git push origin master
上述操作产生如下输出:
Counting objects: 5, done. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 310 bytes, done. Total 3 (delta 1), reused 0 (delta 0) To gituser@git.server.com:project.git 29af9d4..5776472 master ?> master