1.git checkout branch: 切换分支
LOLLICUP@DESKTOP-EF95EEJ MINGW64 /d/www/lollicupStore2 (sun-dev-customer-layout)
$ git checkout master
Switched to branch 'master'
M media/customer/S/E/SELLER_PERMIT.pdf
M media/customer/S/e/Seller_permit.pdf
M media/customer/p/e/permit.jpg
M media/customer/r/e/resale_certificate.pdf
M media/customer/r/e/reseller_permit.pdf
M media/customer/s/e/seller_s_permit.pdf
M media/customer/s/e/sellers_permit.pdf
Your branch is up to date with 'origin/master'.
LOLLICUP@DESKTOP-EF95EEJ MINGW64 /d/www/lollicupStore2 (master)
$ git branch
aaron
* master
storex
sun-dev
sun-dev-customer-layout
sun-dev-yang
2. git checkout -b branch: 基于当前分支创建新的分支
下面是基于master分支创建新的分支(master-sun-no-pl-dev)
LOLLICUP@DESKTOP-EF95EEJ MINGW64 /d/www/lollicupStore2 (master)
$ git branch
aaron
* master
storex
sun-dev
sun-dev-customer-layout
sun-dev-yang
LOLLICUP@DESKTOP-EF95EEJ MINGW64 /d/www/lollicupStore2 (master)
$ git checkout -b master-sun-no-pl-dev
Switched to a new branch 'master-sun-no-pl-dev'
M media/customer/S/E/SELLER_PERMIT.pdf
M media/customer/S/e/Seller_permit.pdf
M media/customer/p/e/permit.jpg
M media/customer/r/e/resale_certificate.pdf
M media/customer/r/e/reseller_permit.pdf
M media/customer/s/e/seller_s_permit.pdf
M media/customer/s/e/sellers_permit.pdf
LOLLICUP@DESKTOP-EF95EEJ MINGW64 /d/www/lollicupStore2 (master-sun-no-pl-dev)
$ git branch
aaron
master
* master-sun-no-pl-dev
storex
sun-dev
sun-dev-customer-layout
sun-dev-yang
3. git checkout –b 本地分支名 远程分支名
克隆远程分支到自己的本地分支。
git checkout -b branch origin/branch
例如下面的操作
lollicup@DESKTOP-4M99Q31 MINGW64 /d/www/lollicupStore2 (sun-ios-api)
$ git checkout -b bill-sun-ios-api origin/bill-sun-ios-api
Switched to a new branch 'bill-sun-ios-api'
M media/customer/P/e/Permit.jpg
M media/customer/R/e/Resale_Certificate.pdf
M media/customer/R/e/Reseller_Permit.pdf
M media/customer/S/E/SELLER_PERMIT.pdf
M media/customer/S/e/Seller_permit.pdf
M media/customer/S/e/Seller_s_Permit.pdf
M media/customer/s/e/sellers_permit.pdf
Branch 'bill-sun-ios-api' set up to track remote branch 'bill-sun-ios-api' from 'origin'.
lollicup@DESKTOP-4M99Q31 MINGW64 /d/www/lollicupStore2 (bill-sun-ios-api)
lollicup@DESKTOP-4M99Q31 MINGW64 /d/www/lollicupStore2 (bill-sun-ios-api)
$ git branch
aaron
bill
* bill-sun-ios-api
bill_emailbug
bill_shopreview
获取远程仓库的bill-sun-ios-api 分支到自己本地仓库的分支