简体   繁体   English

VSTS git:如何从远程存储库获取“分支”?

[英]VSTS git: How to get the “branch” from the remote repository?

In TFS: We had a "master" branch called main. 在TFS中:我们有一个名为main的“ master”分支。 When we worked on features, we would branch the "master" into a "feature-branch". 当我们处理要素时,我们会将“母版”分支为“要素分支”。 TFS would physically make a "copy" of the "master" branch in the working folder for the "feature-branch" that we can work on. TFS会为我们可以处理的“功能分支”在工作文件夹中物理地复制“主”分支。

How does it work in VSTS git? 它在VSTS git中如何工作? I created a branch of the "master" called "feature-branch". 我创建了“主”的一个分支,称为“功能分支”。 I pulled the latest from the repository. 我从存储库中提取了最新的。 How do I switch to the "feature-branch" from the "master" so I can work on the features? 如何从“母版”切换到“功能分支”,以便可以使用这些功能? Is it as easy as just clicking "Branches" in the VSTS menu and then click the "feature-branch" in the "remote/origin" folder? 它像单击VSTS菜单中的“分支”,然后单击“远程/原始”文件夹中的“功能分支”一样简单吗?

If your origin is already set up, you just check it out. 如果您的原点已经建立,则只需将其签出即可。

git checkout feature-branch

To see all your branches 看你所有的分店

git branch -a

This will list them for you. 这将为您列出它们。 If you don't see your remote branch listed, then perform a fetch to get a new list of branches and tags from your remote 如果未列出远程分支,请执行获取操作以获取远程分支的新列表和标签

git fetch

If you want to create feature-branch locally, then you can do that, too. 如果要在本地创建功能分支,那么也可以这样做。 This is my normal workflow. 这是我正常的工作流程。 To do this, you create the local branch, check it out and then you can push it to your remote. 为此,您可以创建本地分支,将其检出,然后将其推送到您的遥控器。 Like this: 像这样:

git checkout -b feature-branch
git push -u origin feature-branch

The first line created and branch and checks it out in one hit. 第一行创建并分支,并在一个命中中将其签出。 The second line pushed your new branch to the remote (named origin). 第二行将您的新分支推送到远程服务器(命名为origin)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何获得远程分支并使用git和vsts切换到它? - How to get remote branch and switch to it with git and vsts? 如何通过VSTS REST API在VSTS的GIT存储库中的特定分支中获取所有文件? - How to get all files in a specific branch in a GIT repository in VSTS through VSTS REST API? 如何干净地获取/复制远程 git 分支到本地存储库 - How to cleanly get/copy a remote git branch to local repository 如何在开发分支git仓库(VSTS)中将特定文件夹获取到我的本地目录 - How to get a specific folder in develop branch git repository (VSTS) to my local directory 如何从不同的git仓库获取和跟踪远程分支 - How to fetch and track remote branch from different git repository 如何删除远程Git存储库上的HEAD分支? - How to delete HEAD branch on remote Git repository? 如何为svn存储库创建git远程分支 - How to create git remote branch for svn repository Git:如何更改远程存储库上的活动分支? - Git: how to change active branch on remote repository? 如何创建VSTS GIT存储库的远程副本(不是本地克隆) - How to create a remote copy (not local clone) of a VSTS GIT repository 如何删除远程 git 存储库(如 VSTS)中的悬空提交 - How to remove dangling commits in remote git repository like VSTS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM