常用的git經典命令

刪除遠程分支

git push --delete origin dev 或者 git push origin :dev

刪除本地分支

git branch -D foo

取消關聯遠程分支

git remote remove origin

改變關聯

git branch --set-upstream-to=origin/dev dev

強推分支到主分支

git push origin dev:master -f

查看每個版本那些文件改變

git lol --stat
git lg --stat
git lol -p(每次提交的差異) -2
git lol --grep "描述"

git diff
git diff head~2 app/Http/Controllers/Api/User/OauthController.php

顯示某個文件的變化

git show --stat app/Http/Controllers/Api/User/OauthController.php

修改描述

git rebase -i head~1

git commit --amend

顯示衝突文件

git diff --name-only --diff-filter=U

用遠程的分支來創建本地分支

git clone remote_repo -b dev

git stash用法

git stash save "描述"
git stash list //緩存列表
git stash show stash@{1} //顯示改動
git stash show -p stash@{1} 顯示改動細節差異 
git stash apply //應用存儲
git stash pop //恢復緩存並刪除
git stash drop stash@{1} //刪除緩存
git stash clear //清空緩存

git tag用法

git tag -a 1.0 -m "描述"
git tag //查看
git tag -d 1.0 //刪除本地tag
git push origin :refs/tags/1.0 //刪除遠程tag
git push --tags //提交tag

常用別名

git config --global alias.df "diff --name-only --diff-filter=U"

git config --global alias.lol "log --pretty=oneline --abbrev-commit --graph --decorate"

git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

經典文章

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章