如何在Git中分支分支? [英] How to fork a branch in Git?

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

问题描述

好的,所以我需要分叉一个项目,克隆它,而不是。事情是主分支是2000左右提交我需要使用的分支。我如何分支不是主要回购。



我分叉它,我意识到我有叉主分支。我做了一个 git pull origin 2-0-stable ,并且有大量的合并冲突。呃哦。



我想要做的就是在master旁边有另一个分支,就是精确和回购中的分支相同。 / b>

解决方案

您应该签出其他分行:

  git checkout origin 2-0-stable 

Git会自动检测到你不'没有一个具有该名称的本地分支,但是您有一个具有该名称的远程分支。它将创建一个本地分支 2-0-stable ,它将与 origin / 2-0-stable 相同。并将配置跟踪。



如果您想从一开始就处于此状态,您应该 git clone - 分支选项。

  git clone --branch 2- 0稳定< git url> 

这将克隆回购,但会直接检出指定的分支。


Alright, so I need to fork a project, clone it, and what not. Thing is the master branch is 2000 or so commits ahead of the branch I need to be using. How do I fork a branch and not the main repo.

I forked it and I realized I had forked the master branch. I do a git pull origin 2-0-stable and there are tons of merge conflicts. Uh oh.

All I want to do is have another branch beside master that is the exact same as the one up on the repo.

解决方案

You should checkout the other branch:

git checkout origin 2-0-stable

Git will automatically detect that you don't have a local branch with that name, but you have a remote branch with that name. It will create a local branch 2-0-stable which will be the same as origin/2-0-stable and will have tracking configured.

If you want to be in this state from the beginning you should git clone with the --branch option.

git clone --branch 2-0-stable <git url>

This will clone the repo, but will directly check out the specified branch.

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

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