(ZZ) git 常用命令

來源:互聯網
上載者:User

標籤: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 log #查看提交曆史

  • $ git log -p <file> #查看指定檔案的提交曆史

  • $ git blame <file> #以列表方式查看指定檔案的提交曆史

撤消
  • $ 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圖片下載

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.