git init
將當(dāng)前文件夾初始化成git倉庫
git clone <address>
從< address >檢出倉庫饺鹃,< address > 可以是本地倉庫功戚,也可以是遠(yuǎn)程倉庫
git remote add origin <server>
如果倉庫不是檢出的譬淳,可以指定遠(yuǎn)程倉庫,server是遠(yuǎn)程倉庫地址
git status
查看狀態(tài)
git diff
查看變更的內(nèi)容
git add <fileName>
git add .
將更改的文件提交到暫存區(qū) git add .
是添加(除去ignore)所有改動的文件
git mv <old> <new>
更改文件名
git rm <file>
刪除文件
git commit -m "message"
將add后的文件提交到head中毛甲,等待push到遠(yuǎn)程倉庫
git push <remote> <master>
將commit的文件提交到遠(yuǎn)程倉庫
git pull
下載代碼并快速合并
git reset --hard HEAD
撤消工作目錄中所有未提交文件的修改內(nèi)容(hard只是其中一個可選項奋单,后面再細(xì)說)
git checkout HEAD <file>
撤銷指定的未提交文件的修改內(nèi)容
git revert <commit>
撤銷指定的提交
git log
查看提交歷史
git log -p <file>
查看指定文件的提交歷史
git branch
顯示所有的本地分支
git checkout <branch/tag>
切換到指定分支/標(biāo)簽
git branch <branch>
創(chuàng)建新分支
git branch -d <branch>
刪除本地分支
git tag
顯示所有本地標(biāo)簽
git tag <tagName>
創(chuàng)建標(biāo)簽
git tag -d <tagName>
刪除標(biāo)簽
git remote -v
查看遠(yuǎn)程版本庫信息
git remote show <remote>
查看指定遠(yuǎn)程版本庫信息
git fetch <remote>
從遠(yuǎn)程庫獲取代碼
git push <remote> :<branch/tagName>
刪除遠(yuǎn)程分支/標(biāo)簽
git push --tags
上傳所有標(biāo)簽