🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
Byron 克隆库,他决定实现基本字符串操作。于是,他创建文件string.c,在添加内容到 string.c 会这个样子。 #include <stdio.h> int my_strlen(char *s) { char *p = s; while (*p) ++p; return (p - s); } int main(void) { int i; char *s[] = { "Git tutorials", "Tutorials Yiibai" }; for (i = 0; i < 2; ++i) printf("string lenght of %s = %d ", s[i], my_strlen(s[i])); return 0; } 他编译和测试代码,一切工作正常。现在,他可以放心地添加这些修改到版本库。 Git 添加操作添加文件到暂存区。 [byron@CentOS project]$ git status -s ?? string ?? string.c [byron@CentOS project]$ git add string.c Git是显示文件名前的问号。显然,这些文件不属于Git,Git 不知道该怎么用这些文件。这就是为什么Git是文件名前显示问号。 Byron 添加文件到存储区域,git的状态命令将显示文件暂存区域。 [byron@CentOS project]$ git status -s A string.c ?? string 要提交更改他用git 的commit 命令-m选项。如果我们省略-m选项git会打开文本编辑器,在这里我们可以写多行提交信息。 [byron@CentOS project]$ git commit -m 'Implemented my_strlen function' 上面的命令会产生以下结果。 [master cbe1249] Implemented my_strlen function 1 files changed, 24 insertions(+), 0 deletions(-) create mode 100644 string.c 提交后查看日志信息,他使用 git 日志命令。它会显示提交ID所有提交的信息,提交作者,提交日期和提交的 SHA-1散列。 [byron@CentOS project]$ git log 上面的命令会产生以下结果。 commit cbe1249b140dad24b2c35b15cc7e26a6f02d2277 Author: Byron <xiaobosun@gridinfo.com.cn> Date: Wed Sep 11 08:05:26 2015 +0530 Implemented my_strlen function commit 19ae20683fc460db7d127cf201a1429523b0e319 Author: Sampson <sampson@12xue.com> Date: Wed Sep 11 07:32:56 2015 +0530 Initial commit