到目前为止,Tom和Jerry都在使用手动命令来编译他们的项目.现在,Jerry决定为他们的项目创建Makefile,并为文件"string.c"指定一个正确的名称.
[jerry@CentOS project]$ pwd/home/jerry/jerry_repo/project[jerry@CentOS project]$ lsREADME src[jerry@CentOS project]$ cd src/[jerry@CentOS src]$ git add Makefile[jerry@CentOS src]$ git mv string.c string_operations.c[jerry@CentOS src]$ git status -sA MakefileR string.c −> string_operations.c
Git在文件名前显示 R ,表示文件已重命名.
对于提交操作,Jerry使用-a标志,这使得git commit自动检测修改后的文件.
[jerry@CentOS src]$ git commit -a -m 'Added Makefile and renamed strings.c tostring_operations.c '[master 94f7b26] Added Makefile and renamed strings.c to string_operations.c1 files changed, 0 insertions(+), 0 deletions(-)create mode 100644 src/Makefilerename src/{string.c => string_operations.c} (100%)
提交后,他将更改推送到存储库.
[jerry @ CentOS src] $ git push origin master
上面的命令会产生以下结果 :
Counting objects: 6, done.Compressing objects: 100% (3/3), done.Writing objects: 100% (4/4), 396 bytes, done.Total 4 (delta 0), reused 0 (delta 0)To gituser@git.server.com:project.git7d9ea97..94f7b26 master −> master
现在,其他开发人员可以通过更新本地存储库来查看这些修改.