1

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

Harish
  • 1,469
  • 16
  • 43

1 Answers1

1

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

upstream and fork

(git remote man page)

git remote add upstream url://upstream/repo

The OP opensourcelover mentions seeing this:

git remote -v, 

origin [email protected]:username/project.git (fetch) 
origin [email protected]:username/project.git (push) 
upstream [email protected]:username/project.git (fetch) 
upstream [email protected]: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?".

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250