Chr*_*ian 127 git github git-fetch git-branch git-fork
我从GitHub上的回购中分得一杯羹.我想从另一个用户的fork上的分支获取代码.
我必须将此用户的整个仓库克隆到单独的本地仓库,还是可以执行类似的操作git checkout link_to_the_other_users_branch
?
ama*_*loy 229
$ git remote add theirusername git@github.com:theirusername/reponame.git
$ git fetch theirusername
$ git checkout -b mynamefortheirbranch theirusername/theirbranch
Run Code Online (Sandbox Code Playgroud)
请注意,在第一步中添加遥控器时,可以使用多个"正确"的URI.
git@github.com:theirusername/reponame.git
是一个基于SSH的URIhttps://github.com/theirusername/reponame.git
是一个HTTP URI您更喜欢使用哪一个取决于您的情况:GitHub有一篇帮助文章解释了差异并帮助您选择:我应该使用哪个远程URL?
Mat*_*ski 23
amalloy的建议对我不起作用.这样做:
git remote add theirusername https://github.com/theirusername/reponame
git fetch theirusername
git checkout -b mynamefortheirbranch theirusername/theirbranch
Run Code Online (Sandbox Code Playgroud)
资源: