github fork confusion

牧云@^-^@ 提交于 2019-12-23 04:03:43

问题


I followed this https://help.github.com/articles/fork-a-repo post to clone a repository locally. After doing that another developer created a branch to the main repository and added some features to that branch. My question is

  1. How do I get that branch into my fork.
  2. Can I get that missing branch again to my local using git pull upstream/missing_branch command?

Thank you


回答1:


You need to add a remote repo 'upstream' in the local repo (which has for origin your fork)

(git remote man page)

git remote add upstream url://upstream/repo

The OP opensourcelover mentions seeing this:

git remote -v, 

origin git@github.com:username/project.git (fetch) 
origin git@github.com:username/project.git (push) 
upstream git@github.com:username/project.git (fetch) 
upstream git@github.com:username/project.git (push) 

If your origin is the same as your upstream remote repo, you can replace that url by the https one for that upstream:

git remote set-url upstream https://github.com/originalDevName/originalRepoName

That way, you can git fetch upstream and get the new branch.

If you need to work on that new branch, you can now declare it:

git branch -u upstream/foo foo

See "How do you make an existing Git branch track a remote branch?".



来源:https://stackoverflow.com/questions/15956343/github-fork-confusion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!