標籤:style http io strong 檔案 ar 代碼 工作
建立版本庫
$ git clone <url> #複製遠程版本庫
$ git init #初始化本地版本庫
修改和提交
$ git status #查看狀態
$ git diff #查看變更內容
$ git add . #跟蹤所有改動過的檔案
$ git add <file> #跟蹤指定的檔案
$ git mv <old> <new> #檔案改名
$ git rm <file> #刪除檔案
$ git rm --cached <file> #停止追蹤檔案但不刪除
$ git commit -m “commit message” #提交所有更新過的檔案
$ git commit --amend #修改最後一次提交
查看提交曆史
撤消
$ git reset --hard HEAD #撤消工作目錄中所有未提交檔案的修改內容
$ git checkout HEAD <file> #撤消指定的未提交檔案的修改內容
$ git revert <commit> #撤消指定的提交
分支與標籤
$ git branch #顯示所有本地分支
$ git checkout <branch/tag> #切換到指定分支或標籤
$ git branch <new-branch> #建立新分支
$ git branch -d <branch> #刪除本地分支
$ git tag #列出所有本地標籤
$ git tag <tagname> #基於最新提交建立標籤
$ git tag -d <tagname> #刪除標籤
合并與衍合
$ git merge <branch> #合并指定分支到當前分支
$ git rebase <branch> #衍合指定分支到當前分支
遠程操作
$ git remote -v #查看遠程版本庫資訊
$ git remote show <remote> #查看指定遠程版本庫資訊
$ git remote add <remote> <url> #添加遠程版本庫
$ git fetch <remote> #從遠程庫擷取代碼
$ git pull <remote> <branch> #下載代碼及快速合并
$ git push <remote> <branch> #上傳代碼及快速合并
$ git push <remote> :<branch/tag-name> #刪除遠程分支或標籤
$ git push --tags #上傳所有標籤
文章來源:
https://gitcafe.com/GitCafe/Help/wiki/Git-%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4%E9%80%9F%E6%9F%A5%E8%A1%A8
http://pjq.me/wiki/doku.php?id=work:git-guide
Git Cheat Sheet < CN > (#Version 0.1)
PDF 版本下載 / PNG圖片下載