Git使用的人越來越多,它是一個非常好的版本控制軟件,GitHub就是一個使用Git作為版本控制的一個遠程倉庫,上面有很多免費資源,學習Git有助于我們共享資源。
在Git操作窗口中要用到的命令:
ls clear cd pwd touch mkdir(不詳解只列出來,不懂的可以跳過)
一、初始化本地Git:
用戶名:git config --global user.name "Zhe Guo"
郵箱:? git config --global user.email "ZheGou@126.com"
二、創建本地版本庫
就是把你存放文件的目錄寫入文件,讓它變成Git庫,文件是放在該目錄下自動生成的一個隱藏文件夾中。(先在f盤中根目錄下建一個gi目錄)
用git init命令
lt4@ltu MINGW64 /f/gi
$ git init
Initialized empty Git repository in F:/gi/.git/
三、把文件添加到暫存區
把目錄中的1.txt文件添加到暫存區(你需要在目錄中先建一個1.txt文件)
用git add 1.txt
lt4@ltu MINGW64 /f/gi (master)
$ ls
1.txt? testgit/
lt4@ltu MINGW64 /f/gi (master)
$ git add 1.txt
把1.txt用git add添加到暫存區
沒有任何提示說明已經添加成功
四、把暫存區中的文件提交到倉庫
用git commit -m命令
lt4@ltu MINGW64 /f/gi (master)
$ git commit -m "1.txt 第一次提交"
[master (root-commit) 7963edc] 1.txt 第一次提交
1 file changed, 2 insertions(+)
create mode 100644 1.txt
五、查看暫存區是否有文件未提交
用git status命令
沒有未提交的文件
lt4@ltu MINGW64 /f/gi (master)
$ git status
On branch master
nothing to commit, working tree clean
六、查看文件改過什么內容
用git diff 1.txt命令
lt4@ltu MINGW64 /f/gi (master)
$ git diff 1.txt
diff --git a/1.txt b/1.txt
index f45a072..5ab530e 100644
--- a/1.txt
+++ b/1.txt
@@ -1,4 +1,7 @@
? a=1
?? b=4+87
-d=a+b
+//?+e=38
\ No newline at end of file
七、提交文件到倉庫
第一步是git add 第二步是git commit
lt4@ltu MINGW64 /f/gi (master)
$ git add 1.txt
lt4@ltu MINGW64 /f/gi (master)
$ git commit -m "1.txt 第二次提交"
[master c452fe5] 1.txt 第二次提交
1 file changed, 4 insertions(+), 1 deletion(-)
待繼:::