====== Git ====== 是一個自由且開放原始碼, 分散式架構的版本控制系統 designed to handle everything from small to very large projects with speed and efficiency. ===== Git網路資源 ===== * 官網 http://git-scm.com/ * http://zh.wikipedia.org/wiki/Git * [[http://github.com/guides/git-podcasts|Guides: Git Podcasts]] * [[http://www.kernel.org/pub/software/scm/git/docs/user-manual.html|Git User's Manual]] * [[http://www.qweruiop.org/nchcrails/posts/49|Git 原始碼管理]] * [[http://www.bitsun.com/documents/gittutorcn.htm|Git中文教程]] * [[http://www.bitsun.com/documents/GitUserManualChinese.html|Git 用户手册(1.5.3 及後續版本適用)]] * Scott Chacon 將其著作 [[http://progit.org/book/|Pro Git]] 書籍,發佈為 [All content under Creative Commons Attribution-Non Commercial-Share Alike 3.0 license],有興趣者可直接線上閱讀。 * [[http://www.ibm.com/developerworks/cn/linux/l-git/|使用 Git 管理源代碼]] * [[http://zh-tw.whygitisbetterthanx.com/|Why Git is Better than X]] ==== Git for Windows ==== * [[http://code.google.com/p/msysgit/|msysgit - Git on Windows]] * [[http://code.google.com/p/tortoisegit/|TortoiseGit The coolest Interface to (Git) Version Control]] * [[http://www.lostechies.com/blogs/jason_meridth/archive/2009/06/01/git-for-windows-developers-git-series-part-1.aspx|Git For Windows Developers – Git Series - Part 1]] ===== Git 指令表 ===== git init # 開始用 Git 來管理 git add . # 把所有檔案加入 Git git commit -a # 做成一個版本 git commit -a -m "your message here" # commit 時直接寫訊息, 不用到下個螢幕上寫 git add mine.txt # 把 mine.txt 加入管理 git tag v0.02 # 本版別名取為 v0.02 git tag v0.03 40e3e # 把版本 40e3e 取名為 v0.03; git status # 查詢從上個版本到現在哪些檔案被修改 git diff # 查詢從上個版本到現在哪幾行被修改 git diff v0.01 v0.03 # 查詢兩個版本間的差異 git diff v0.01:story.txt v0.03:story.txt # 查詢兩個版本間某個檔案的差異 git log # 查詢有史以來哪幾個檔案被修改 git log -p # 查詢有史以來哪幾行被修改 git log --stat --summary # 查詢每個版本間變動的檔案跟行數 git show v1.01 # 查詢 v1.01 版裡的修改內容 git show v1.01:story.txt # 叫出在 v1.01 版時的 story.txt 檔案 git show v1.01:story.txt > test.txt # 把 v1.01 版的 story.txt 抓出來,放入一個叫 test.txt 的檔案 git show HEAD # 看此版本修改的資料 git show HEAD^ # 看此版本前一版的修改的資料 git show HEAD^^ # 看此版本前前一版的修改的資料 git show HEAD~4 # 看此版本前前前前一版的修改的資料 >_< git grep "貓" v0.01 # 查詢 0.01 版裡頭有沒有貓 git grep "熊" # 查詢現在的版本裡有沒有熊 git branch 加英文版 # 建立新的分枝叫 "加英文版" git branch # 查看現有的分枝 git branch beta v0.5 # 依照 "v0.5" 版裡的內容來建立一個叫 "beta" 的分枝 git checkout 加英文版 # 換到 "加英文版" 的分枝上 git checkout master # 換到主幹上 git branch -d 加英文版 # 刪除 "加英文版" 分枝 gitk # 版本瀏覽軟體 git gui # 瀏覽從上一版本到現在變動的地方; 沒辦法顯示中文 git gc # 維護 Git 的資料庫 git fsck --full # 同上, 三不五時下次指令