Git命令 切换分支
2018-08-20 本文已影响0人
狂奔的大蜗牛
1、查看远程分支
项目根目录下执行以下命令:
xiaoqi:dev xq$ git branch -a
* feature-hr
remotes/origin/HEAD -> origin/master
remotes/origin/feature-finance
remotes/origin/feature-hr
remotes/origin/master
2、查看本地分支
xiaoqi:dev xq$ git branch
* feature-hr
3、切换分支
xiaoqi:dev xq$ git checkout -b feature-finance origin/feature-finance
Branch feature-finance set up to track remote branch feature-finance from origin.
Switched to a new branch 'feature-finance'
xiaoqi:dev xq$
切换后的本地分支
xiaoqi:dev xq$ git branch
* feature-finance
feature-hr
4、切回master分支
xiaoqi:dev xq$ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.