如何在git中切换到不同的远程分支 [英] How to switch to a different remote branch in git

查看:1334
本文介绍了如何在git中切换到不同的远程分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个本地分支和3个远程分支,并希望两者都在同一分支上。

I have 3 local and 3 remote branches and want to be on the same branch on both.

在本地:

git branch
  A
* B
  master

git branch -r
  origin/A
  origin/B
  origin/master

on remote:

on remote:

git branch
  A
  B
* master

我可以提交,推送和抽取B,但是我的更新钩子部署了主B,我想因为远程分支仍然设置为主。我使用以下方法创建了分支B:

I am able to commit, push and pull B but my update hook deploys master instead of B, I suppose because the remote branch is still set to master. I created branch B using:

git branch B
git checkout B
git push origin B


推荐答案

据我所知,没有办法改变遥控器当前分支 git push 。推送只会将您的本地更改复制到该存储库中。通常你推送的遥控器应该是 - bare ,没有工作目录(因此没有当前分支)。

As far as I know, there's no way to change a remote's current branch with git push. Pushing will just copy your local changes up into that repository. Typically remotes you push to should be --bare, without a working directory (and thus no "current branch").

这篇关于如何在git中切换到不同的远程分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆