Git 命令

git init :命令把這個目錄變成Git可以管理的倉庫

Initialized empty Git repository in
git add {文件名} :把文件添加到倉庫


git commit -m "{備註}" :把文件提交到倉庫

[master (root-commit) cb926e7] {備註}
 1 file changed, 2 insertions(+)
 create mode 100644 {文件名}
git status :倉庫當前的狀態(有改動/無改動)

# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#    modified:   {文件名}
#
no changes added to commit (use "git add" and/or "git commit -a")
# On branch master
nothing to commit (working directory clean)
git diff {文件名} :查看文件修改內容

diff --git a/{文件名} b/{文件名}
index 46d49bf..9247db6 100644
--- a/{文件名}
+++ b/{文件名}
@@ -1,2 +1,2 @@
-Git is a version control system.
+Git is a distributed version control system.
 Git is free software.
git log (--pretty=oneline): 版本歷史(記錄顯示成單行)

commit 91151d92500d352c70a42ea7caf936ab82135bbe
Author: Stussy <[email protected]>
Date:   Thu Mar 30 23:07:57 2017 +0800

    append GPL

commit ca91a986524aeeea5173006a05515eb0748ed641
Author: Stussy <[email protected]>
Date:   Thu Mar 30 22:58:11 2017 +0800

    add distributed

commit 8e409e008b5589750600a866fc73905e318f7f87
Author: Stussy <[email protected]>
Date:   Thu Mar 30 22:40:32 2017 +0800

    wrote a  readme ifle
git reset --hard (HEAD^/commit_id) : 版本回退到(上個版本/版本號:前幾位即可)

HEAD is now at ea34578 add distributed
HEAD is now at 3628164 append GPL
git reflog : 命令記錄

ea34578 HEAD@{0}: reset: moving to HEAD^
3628164 HEAD@{1}: commit: append GPL
ea34578 HEAD@{2}: commit: add distributed
cb926e7 HEAD@{3}: commit (initial): wrote a readme file








發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章