[英]git - how to set a remote branch out of a branch in upstream?
Use case - I have a code base on github, which has several branches. 用例-我有一个基于github的代码,该代码具有多个分支。 eg developer, integration, regression, production, etc. I usually use this command to add remote branch:
git remote add upstream <repo link>.git
例如开发人员,集成人员,回归人员,生产人员等。我通常使用此命令来添加远程分支:
git remote add upstream <repo link>.git
So, git remote -v
shows as below: 因此,
git remote -v
显示如下:
upstream <repo link>.git (fetch)
upstream <repo link>.git (push)
but if remote has a branch then what command should I use to set to that branch to? 但是,如果remote有一个分支,那么应该使用什么命令将该分支设置为?
To make a new remote branch to local, you can use git fetch
. 要在本地创建一个新的远程分支,可以使用
git fetch
。
After that, you will find the branch by git branch -a
. 之后,您将通过
git branch -a
找到git branch -a
。
If you want to work on the new branch, just use git checkout branchname
. 如果要在新分支上工作,只需使用
git checkout branchname
。
Run git fetch
or git pull
to bring up the remote changes including new branches. 运行
git fetch
或git pull
出远程更改,包括新分支。
Run git branch -a
to list down all the remote branches. 运行
git branch -a
列出所有远程分支。
To move or work with fetched remote branch use 要移动或使用获取的远程分支使用
Syntax: git checkout -t remotes/upstream/branchname
Example: git checkout -t remotes/origin/branchname
Here -t will create local branch with upstream branch mapping. 在这里-t将使用上游分支映射创建本地分支。 So the next push/pull/fetch operation will not ask you to run
git branch --set-upstream-to
sometime. 因此,下一个推/拉/取操作将不会要求您
git branch --set-upstream-to
某个时候运行git branch --set-upstream-to
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.