2013年7月3日 星期三

Basic Git

之前對Git一直矇懞懂懂QQ,最近發現Git實在很強大,簡單記錄一下本機端Git的使用情境
參考資料
1. flow chart:


2. 一些git狀態的指令:
a. 列出目前git status
git status
b. 列出簡單的git commit資訊
git log
output example:
commit 15d8a826c79d3f56c4d0d68d72c59841657a3479
Author: chang-ning 
Date:   Wed Jul 3 23:40:27 2013 +0800

    second commit

commit e78139fb261b8a7f46c3cd2e2fe07c2bee205d65
Author: chang-ning 
Date:   Wed Jul 3 22:40:42 2013 +0800

    first commit
c. 列出比較詳細的git commit資訊
git log --stat
output example:
commit 15d8a826c79d3f56c4d0d68d72c59841657a3479
Author: chang-ning 
Date:   Wed Jul 3 23:40:27 2013 +0800

    second commit

 testgit.py |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

commit e78139fb261b8a7f46c3cd2e2fe07c2bee205d65
Author: chang-ning 
Date:   Wed Jul 3 22:40:42 2013 +0800

    first commit

 testgit.py |    5 +++++
 1 file changed, 5 insertions(+)
d. 列出更詳細的git commit資訊
git log -p
output example(會呈現像less指令的界面):
commit 15d8a826c79d3f56c4d0d68d72c59841657a3479
Author: chang-ning 
Date:   Wed Jul 3 23:40:27 2013 +0800

    second commit

diff --git a/testgit.py b/testgit.py
index feabe2f..3fe9a77 100644
--- a/testgit.py
+++ b/testgit.py
@@ -1,5 +1,5 @@
 import sys
-
+import os
 print "HELLO WORLD"
 print "CHANGE HELLO WORLD"
 print "YOYOYO"

commit e78139fb261b8a7f46c3cd2e2fe07c2bee205d65
Author: chang-ning 
Date:   Wed Jul 3 22:40:42 2013 +0800

    first commit

diff --git a/testgit.py b/testgit.py
index abe75ff..feabe2f 100644
--- a/testgit.py
+++ b/testgit.py
@@ -1,3 +1,8 @@
 import sys
 
 print "HELLO WORLD"
+print "CHANGE HELLO WORLD"
+print "YOYOYO"
+
+for i in range(3):
+   print 'kerker'
3. 最簡單的remote操作:
a. 加入存放code的remote(ps. 可以無限加入,官方範例推薦第一個新的remote將名稱設成"origin")
git add remote remote_名稱 remote_URL
#example
git add remote kertest https://github.com/crazyguitar/kertest.git
b. 把code或file push到remote
git push remote_名稱 branch_name
#example
git push kertest master
c. 把不要的remote刪除
git remote rm 名稱
#example
git remote rm kertest
d. 列出加入的remote
git remote

沒有留言:

張貼留言