Tom cập nhật repository nội bộ và tìm mã nhị phân được biên dịch trong thư mục src. Sau khi quan sát thông báo commit, anh ta nhận ra rằng mã này được thêm bởi Jerry.
[tom@CentOS src]$ pwd/home/tom/project/src[tom@CentOS src]$ lsMakefile string_operations string_operations.c[tom@CentOS src]$ file string_operationsstring_operations: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (usesshared libs), for GNU/Linux 2.6.18, not stripped[tom@CentOS src]$ git logcommit 29af9d45947dc044e33d69b9141d8d2dad37cc62Author: Jerry Mouse <jerry@tutorialspoint.com>Date: Wed Sep 11 10:16:25 2013 +0530Added compiled binary
VCS chỉ được sử dụng để giữ các code nguồn và không biểu diễn được các mã nhị phân. Vì thế, Tom quyết định dọn các file này từ trong repository. Với các thao tác xa hơn, anh ta sử dụng lệnh git rm.
[tom@CentOS src]$ lsMakefile string_operations string_operations.c[tom@CentOS src]$ git rm string_operationsrm 'src/string_operations'[tom@CentOS src]$ git commit -a -m "Removed executable binary"[master 5776472] Removed executable binary1 files changed, 0 insertions(+), 0 deletions(-)delete mode 100755 src/string_operations
Sau khi commit, anh ta push những thay đổi tới repository.
[tom@CentOS src]$ git push origin master
Lệnh trên sẽ tạo ra kết quả sau:
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.git29af9d4..5776472 master −> master
Theo Tutorialspoint
Bài trước: Hoạt động Rename trong Git
Bài tiếp: Sửa lỗi trong Git