活動網址:http://sitcon.kktix.cc/events/sitcon-workshop-2014-ncku-git
上課講義:http://denny0223.github.io/SITCON-workshop-2014-ncku-git/
以前就曾經聽說過Git這東西
可是我一直認為自己寫code
只要編好檔名就夠了 (科目_作業#_日期_v# , # 為數字)
這次聽完課
才了解Git的方便之處
用法(for Windows)
(1)下載Git for windows 並安裝
(2)選擇資料夾並右鍵選擇 Git Init Here
(3)選擇該資料夾並右鍵選擇 Git Bash 開始使用 Git
Git 指令:
(a)
設定lg為縮寫作為查看log之指令
git config --global alias.lg "log --color --graph --all --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --"
設定使用者名稱
git config --global user.name "Your Name"
設定郵件地址
git config --global user.email "you@example.com"
(b) 查看狀態
git status
(c) 加入追蹤名單
git add 檔名
ps:
git add .
為將所有檔案加入
git add *.c
將所有.c檔加入
(d) 建立還原點
git commit
or
git commit -m "first commit"
(e) 恢復到某個還原點
git reset --hard "版本"
git reset --hard HARD^1 往前一個版本
(f) 查看某個還原點 // 要commit過 或是 stash過
git checkout <revision>
or
git checkout <revision> <file>
(g) 暫存
git stash
or
git stash pop
沒有留言:
張貼留言