GitHub入門(一)
一、在本地熟悉git簡單命令
在安裝和註冊了Git後:
1.首先要建立一個版本庫。 右鍵桌面,點選gitbash
2 在合適的位置建立一個資料夾,例建立一個名為helloANN的資料夾。
$ mkdir helloANN
$ cd helloANN
3.在helloANN中初始化一個空的git本地倉庫。
$ git init
該命令將建立一個名為 .git 的子目錄,這個子目錄含有你初始化的 Git 倉庫中所有的必須檔案。
4.建好倉庫後,建立的新檔案都要放到helloANN目錄下,否則git無法找到這個檔案。例如建了一個helloANN.ipynb檔案到helloANN資料夾下。
5.可以把檔案新增到倉庫啦,從而實現對指定檔案的跟蹤。命令: git add+檔名
$ git add helloANN.ipynb
檢視當前檔案狀態
命令:git status
6.將檔案提交到倉庫中!
命令:git commit -m ”xxx“
$ git commit -m "neual network class definition"
[master (root-commit) 28a6c70] neual network class definition
1 file changed, 47 insertions(+)
create mode 100644 helloANN.ipynb
7.檢視當前檔案狀態
命令:git status
$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
.ipynb_checkpoints/
nothing added to commit but untracked files present (use "git add" to track)
在狀態報告中可以看到新建的helloANN.ipynb檔案出現在 Untracked files 下面。 未跟蹤的檔案意味著 Git 在之前的快照(提交)中沒有這些檔案;Git 不會自動將之納入跟蹤範圍,除非你明明白白地告訴它“我需要跟蹤該檔案”, 這樣的處理讓你不必擔心將生成的二進位制檔案或其它不想被跟蹤的檔案包含進來。 不過現在的例子中,我們確實想要跟蹤管理 README 這個檔案。