【Git】切换到远程分支

本文介绍了如何使用Git命令`gitcheckout-borigin/分支名称`来切换到远程分支,并提到如果不带`-b`会进入detachedHEAD状态。同时,文章还演示了`gitpullorigin分支名称`用于拉取远程分支到本地的操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Git切换到远程分支:git checkout -b origin/分支名称

git checkout -b origin/dev_litianchao
 ┃   ┃        ┃  ┗━ origin/dev_litianchao :远程分支/dev_litianchao分支
 ┃   ┃        ┃      ┃      ┗━ dev_litianchao : 想要拉的分支
 ┃   ┃        ┃      ┗━ origin : 远程分支,所有的远程分支都要带上origin
 ┃   ┃        ┗━ -b : -b 的意思是 base(基础),以当前分支为 base (基础)
 ┃   ┃        	  ┗━ -b : 带上直接切换到这个分支,不带会报错
 ┃   ┗━ checkout : 切换分支
 ┗━ git : 所有的git指令的前边都要带上git

checkout 不带 -b 报错:

$ git checkout origin/dev_litianchao
Note: switching to 'origin/dev_litianchao'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 6641ae75d snmp修复Firmware state状态数值

Git拉取远程分支到本地 git pull origin 3.0.2.36

git pull origin 3.0.2.36
 ┃   ┃    ┃      ┗━ 3.0.2.36 : 远程的分支
 ┃   ┃    ┗━ origin : 远程
 ┃   ┗━ pull : 拉取分支
 ┗━ 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值