git 常用命令
1. git clone? ? ? ? ? ? ? ? ? ? ? ?ssh
克隆倉庫
2. git remote -v
查看遠程倉庫
3. git remote add <name> <remote>
添加源倉庫地址為遠程倉庫
4. git remote rename old new
遠程倉庫重命名
5.???git add
提交到暫存區(qū)
git commit -m "…"
提交到本地倉庫
6. git status
查看當前文件的狀態(tài)
7. git push <remote> <branch>
提交內(nèi)容到遠程倉庫 origin? origin master
8. git checkout -- <file>
撤銷工作區(qū)修改
9. git reset HEAD <file>
暫存區(qū)文件撤銷(不覆蓋工作區(qū))
10. git reset --(soft| mixed|hard) <HEAD~ (num)> | <commit ID>
版本回退
hard: 回退全部,包括HEAD,index,working tree
mixed:回退部分搞旭,包括HEAD座韵,index
soft:只回退HEAD
git log:展示版本修改(日志)
git reflog:詳細地展示版本修改的內(nèi)容(日志)
11.git diff
比較工作區(qū)和暫存區(qū)
git diff HEAD
比較工作區(qū)與本地版本庫中最近一次commit的內(nèi)容
git diff --cached
比較暫存區(qū)與本地版本庫中最近一次commit的內(nèi)容
git diff <commit-id> <commit-id>
比較兩個commit之間的差異
12分支
git branch? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?查看分支
git branch?<name> ? ? ? ? ? ? ? ? ? ? ? ? ? 創(chuàng)建新分支
git push origin <name>? ? ? ? ? ? ? ? ? ? ? 添加遠程分支
git checkout <name>? ? ? ? ? ? ? ? ? ? ? ? 切換分支
git checkout -b <name>? ? ? ? ? ? ? ? ? ? ? 創(chuàng)建并切換分支
git branch?-d ?<name> ? ? ? ????????? ? ? ? ? ?刪除本地分支
git push -d <origin> <branch>? ? ? ? ? ? ? ? 刪除遠程分支
git merge <name>? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?合并
git pull origin master? ? ? ? ? ? ? ? ? ? ? ? ? ? ?遠程倉庫拉取