github checkout常见用法

来源:互联网 发布:五代十国 知乎 编辑:程序博客网 时间:2024/06/08 19:29

1、git checkout branchName 切换分支

$ git branch
 a
 dev
 localBranchName
* localBranchName2
 master
 testdd
$ git checkout a
Switched to branch 'a'

2、git checkout -b branchName 创建并切换分支

     $ git checkout -b ranchName
     Switched to a new branch 'ranchName'

3、git checkout -b|-B test1 origin/test1根据远程某一分支,创建本地分钟,并切换到新分支,-B 代表当分支存在时,重置分支。

$ git checkout -b test1 origin/test1
Branch test1 set up to track remote branch test1 from origin.
Switched to a new branch 'test1'
$ git branch
  a
  dev
  localBranchName
  localBranchName2
  master
  ranchName
* test1
  testdd

根据远程分支device6创建本地分支newBranchName:

git checkout -b newBranchName origin/device6


原创粉丝点击