我从 GitHub 上的一个 repo 分叉出来。我想从另一个用户的分支上的分支获取代码。
我必须将此用户的整个存储库克隆到单独的本地存储库还是可以做类似的事情git checkout link_to_the_other_users_branch
?
我从 GitHub 上的一个 repo 分叉出来。我想从另一个用户的分支上的分支获取代码。
我必须将此用户的整个存储库克隆到单独的本地存储库还是可以做类似的事情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 的 URIhttps://github.com/theirusername/reponame.git
是一个 HTTP URI您更喜欢使用哪一种取决于您的情况。GitHub 有一篇帮助文章解释了区别并帮助您选择:我应该使用哪个远程 URL?
amalloy 的建议对我不起作用。这做到了:
git remote add theirusername https://github.com/theirusername/reponame
git fetch theirusername
git checkout -b mynamefortheirbranch theirusername/theirbranch
资源: