git分支
查看分支
git branch //查看所有分支及當前處於哪個分支
git branch -a //查看遠程分支
git branch --merged //查看已經合併的分支
git branch --no-merged //查看還沒合併的分支
git checkout <branch-name> //切換到某個分支
創建本地分支
git branch <local_branch> //新建一個分支
git checkout -b <local_branch>//新建一個分支並切換到這個分支上
將本地分支更新到遠程分支
git push origin local_branch:remote_branch
這個操作,local_branch必須爲你本地存在的分支,remote_branch爲遠程分支,如果remote_branch不存在則會自動創建分支。
類似,git push origin :remote_branch,local_branch留空的話則是刪除遠程remote_branch分支。
將遠程分支獲取到本地
git fetch //可以將遠程分支信息獲取到本地,
git checkout -b local-branchname origin/remote_branchname //就可以將遠程分支映射到本地命名爲local-branchname 的一分支。
或者 git pull origin local_branch:remote_branch
刪除分支:
git branch -d <branch-name>
合併分支
git merge <branch-name>
e: 將分支btest 合併到主分支master
git checkout master
git merge btest
tag 標籤
將本地tag更新到遠程tag
git push origin local_tag:remote_tag
git push --tags //把本地推送到遠程
將遠程分支獲取到本地
git pull origin local_tag:remote_tag
刪除時:
git tag -d <tag-name>
git diff
git diff --cached
查看已緩存與未緩存的所有改動:
git diff HEAD
顯示摘要而非整個diff :
git diff --stat