如何在GitHub上的其他人的分支上获取分支? [英] How do I fetch a branch on someone else's fork on GitHub?

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

问题描述

我从GitHub上的回购协议中分离出来。我想从另一个用户的分支上的分支获取代码。



我必须将此用户的整个回购协议复制到单独的本地回购协议中,或者可以像 git checkout link_to_the_other_users_branch 那样进行操作吗?

解决方案

  $ git remote add theirusername git@github.com:theirusername / reponame.git 
$ git fetch theirusername
$ git checkout -b mynamefortheirbranch theirusername / theirbranch

请注意,在第一步中添加远程设备时,可以使用多个正确的URI。




  • git@github.com:theirusername / reponame.git 是一个基于SSH的URI

  • https://github.com /theirusername/reponame.git 是一个HTTP URI



您更喜欢使用哪一个取决于您的情况:GitHub有一篇帮助文章解释差异并帮助您选择:哪个REM我应该使用URL吗?


I've forked from a repo on GitHub. I want to get the code from a branch on another user's fork.

Must I clone this user's whole repo to a separate local repo or can I do something like git checkout link_to_the_other_users_branch?

解决方案

$ git remote add theirusername git@github.com:theirusername/reponame.git
$ git fetch theirusername
$ git checkout -b mynamefortheirbranch theirusername/theirbranch

Note that there are multiple "correct" URIs you can use for the remote when you add it in the first step.

  • git@github.com:theirusername/reponame.git is an SSH-based URI
  • https://github.com/theirusername/reponame.git is an HTTP URI

Which one you prefer to use will depend on your situation: GitHub has a help article explaining the difference and helping you choose: Which remote URL should I use?

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

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