標籤:技術 span title targe iba 為什麼 add a1429 create
Jerry 複製庫,他決定實現基底字元串操作。於是,他建立檔案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 Point” }; for (i = 0; i < 2; ++i) printf(“string lenght of %s = %d/n”, s[i], my_strlen(s[i])); return 0; }
他編譯和測試代碼,一切工作正常。現在,他可以放心地添加這些修改到版本庫。
Git 添加操作添加檔案到暫存區。
[[email protected] project]$ git status -s ?? string ?? string.c
[[email protected] project]$ git add string.c
Git是顯示檔案名稱前的問號。顯然,這些檔案不屬於Git,Git 不知道該怎麼用這些檔案。這就是為什麼Git是檔案名稱前顯示問號。
Jerry 添加檔案到儲存地區,git的狀態命令將顯示檔案暫存地區。
[[email protected] project]$ git status -s A string.c ?? string
要提交更改他用git 的commit 命令-m選項。如果我們省略-m選項git會開啟文字編輯器,在這裡我們可以寫多行提交資訊。
[[email protected] 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散列。
[[email protected] project]$ git log
上面的命令會產生以下結果。
commit cbe1249b140dad24b2c35b15cc7e26a6f02d2277 Author: Jerry Mouse <[email protected]> Date: Wed Sep 11 08:05:26 2013 +0530 Implemented my_strlen function commit 19ae20683fc460db7d127cf201a1429523b0e319 Author: Tom Cat <[email protected]> Date: Wed Sep 11 07:32:56 2013 +0530 Initial commit
PS:如果您想和業內技術大牛交流的話,請加qq群(521249302)或者關注公眾 號(AskHarries),謝謝!
Git 執行更改