Git 執行更改

來源:互聯網
上載者:User

標籤:技術   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 執行更改

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.