More Related Content Similar to 大家應該都要會的工具 Git 從放棄到會用1-基礎篇 (20) 大家應該都要會的工具 Git 從放棄到會用1-基礎篇2. 關於我
2
▰Alan Tsai 蔡孟玹
▰後端(攻城)工程師
▻Web Developer - 主要使用 .Net/C# 和 Asp .Net Mvc
▰看小說
▰找到我 – contact@alantsai.net
▻http://blog.alantsai.net - Alan Tsai 的學習筆記
▻{服務}.alantsai.net
▻http://fb.alantsai.net - fb
▻http://ln.alantsai.net – linkeding
▻http://ss.alantsai.net - slideshare
10. 第二代 – CVCS(Centralized) 集中式版控
10
▰有個中央Server記錄版本
▻可以多人使用
▰第一代問題是容易雙方互等
▻在commit(提交)的時候針對有重複的去做修正
▰典型程式有
▻Subversion (SVN),
Team Foundation Server (TFS),
CVS, SourceSafe,
來源:Pro Git P29 Figure1-2
11. 第三代 – D(Distributed)VCS – 分散式版控系統
11
▰不再只有一個中央系統
▻任何人裡面有記錄就是一個Repository
▻隨時可以commit
▻merge before commit
來源:Pro Git P30
Figure1-3
27. 使用組合
27
▰ CLI (powershell) + TortoiseGit
▻ CLI做一般操作
▻ TortoiseGit 做 歷史查詢(log),檔案比對(diff)和處理
conflict
▰ Source Tree + TortoiseGit
▻ Source Tree有點ide的感覺
▻ TortoiseGit在歷史查詢比較清楚
28. 安裝git – CLI工具
28
▰Git for Windows
▰包含git.exe、git bash、 git gui 、git lfs、git flow和Windows Credential Manager
▻https://git-scm.com/download/win
▻chocolate
#沒安裝過choclate 用 admin開啟 cmd 然後執行
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object
System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"
&& SET "PATH=%PATH%;%ALLUSERSPROFILE%chocolateybin"
choco install git.install -params ‘“/NoShellIntegration”'
29. Git for Windows 安裝1
29
▰Windows Explorer Integration
▻建議不要勾,因為其他Gui工具就有提供
30. Git for Windows 安裝2
30
▰Use Git from Git Bash only
▻只有Git Bash能夠跑Git
▰Use Git from the Windows Command prompt
▻在Path上面加git – cmd就可以執行git
▰Use Git and optional Unix tools from Windows Command
Prompt
▻在Path加上git 和 安裝一些Unix工具
31. Git for Windows 安裝3
31
▰Windows 斷行吃 CRLF 而Unix吃 LF
▻Windows建議選第一個
▻Unix建議選第二個
▰這邊是設定版控儲存的斷行方式
▰這個可以安裝完成之後透過 git config設定
git config --system core.autocrlf “true” #第一個選項
git config --system core.autocrlf ”input” #第二個選項
git config --system core.autocrlf ”false” #第三個選項
35. Git Gui
35
▰TortoiseGit (俗稱 小烏龜,TortoiseSvn)
▻支援Windows
▻https://code.google.com/p/tortoisegit/
▰SourceTree
▻支援Windows 和 Mac
▻https://www.atlassian.com/software/sourcetree/overview
▰GitHub For Windows
▰ 更多 Gui 工具
▻ https://git-scm.com/downloads/guis
41. 設定檔案的層級和位置
41
System 層級
Unix - /etc/gitconfig
Windows – {Git安裝路徑}etcgitconfig
使用者層級
Unix - ~/.gitconfig 或者 ~/.config/git/config
Windows - %userprofile%.gitconfig
專案層級
在專案下的 .git/config
輕
43. 設定檔案的層級和位置
43
System 層級
Unix - /etc/gitconfig
Windows – {Git安裝路徑}etcgitconfig
使用者層級
Unix - ~/.gitconfig 或者 ~/.config/git/config
Windows - %userprofile%.gitconfig
專案層級
在專案下的 .git/config
輕git config –-system {參數}
git config –-global {參數}
git config {參數}
48. 非必設定參數 – log編碼問題
48
▰Git log 指令 中文訊息被編碼
▰原因是git log使用page,需要設定編碼到 環境變數
▻開啟[系統管理](Win 8以上快速鍵Win+x y) – 或者點[我的電腦]
點[右鍵]選[系統]
▻參數名稱:
▻參數值:
LC_ALL
C.UTF-8
54. 求救指令 – git help
54
▰git help
▻列出基礎幫助
▰git help {command}
▻例如
▻帶你到官方文件
▰git {command} –h
▻重點介紹
▰不過大家應該還是google比較快
git help add
git add -h
60. 加入一個檔案到版控 – Source Tree
60
▰建立一個ReadMe.md的檔案
▰切換到Source Tree
1. Stage All = git add .
2. 進入到Staging
會被commit的內容
3. 寫入這次記錄的原因
4. Commit(儲存)
64. 關鍵字 – 在賣場買東西
64
▰Working Directory = 推車
▻你把要買的東西放到推車裡面
▰Staging Area = 準備排隊結帳輸送帶
▻排隊結帳會把東西從推車放到輸送帶
▰Commit = 結帳
▻當工作人員幫你刷購買物品結帳
▻
84. Git reset - 從 stage 放回working directory
84
git reset {檔案路徑}
.git
(repo)
Stage
(index)
Working
Directory
git add
git reset
87. Git checkout – 從repo蓋掉working directory
87
▰還有其他用途
▻未來介紹branch在介紹
git checkout {檔案路徑}
.git
(repo)
Stage
(index)
Working
Directory
git add
git reset
git checkout
注意:
執行這個有修改的內容
會被刪掉
96. Git log –歷史
96
▰用git log指令可以看到歷史記錄
▻這個指令有很多參數
git log
git log --oneline --abbrev-commit --all --graph
102. 暫存功能 – git stash
102
▰功能做到一半臨時需要去處理別的怎麼辦?
▰暫存目前在Working Directory的任何修
▰取回第一筆暫存並且把這個暫存刪掉
▰看目前有那些暫存
git stash
git stash pop
git stash list
111. 其他資源
111
▰Git官網 https://git-scm.com/
▻Pro Git https://git-scm.com/book/en/v2
▰Git指令圖解說明
▻http://marklodato.github.io/visual-git-guide/index-en.html
▰連猴子都能夠懂的Git入門指南
▻http://backlogtool.com/git-guide/tw/
▰關注我的部落格 – 特別是git標籤 -
http://blog.alantsai.net/search/label/Git
113. CREDITS
Special thanks to all the people who made and
released these awesome resources for free:
▰ Presentation template by SlidesCarnival
▰ Photographs by Startup Stock Photos
113
Editor's Notes 2005 問世
2008 年搭配github往上升