1

How do I update my branch of my forked repo with the current changes in the master of the main repo. The scenario is I have forked a repo(say A) and also cloned it in my machine. Now I created a branch(say xyz) and created a PR in the original repo. Now it's been a while and the original repo is way ahead in commits. Now I wish to update my branch(xyz) with the latest changes in that file.

I updated my local by creating an upstream, fetching and pulling it. This worked for the master branch. But if I do the same with xyz it says:

fatal: Couldn't find remote ref xyz.

I am not able to figure out the issue.

Yathartha Joshi
  • 716
  • 1
  • 14
  • 29

1 Answers1

0

If it worked for the master of your forked project. On your branch xyz, you can do :

git pull origin master 

If you try pulling the from the remote, it might fail since there is no link between the branch you created(xyz) on the forked project and the original project.

Couldn't find remote ref xyz

states the same message anyway. In order to fetch some remote branch to your local branch, you should follow the syntax:

git fetch <remote> <rbranch>:<lbranch> 

as explained by @Mark here.

Naman
  • 27,789
  • 26
  • 218
  • 353
  • but `origin` points to the address of my forked repo in github, where I haven't made the changes. So if I `pull` as you said it will pull changes of my forked repo in github(which is way behind the original repo) – Yathartha Joshi Sep 03 '17 at 14:29
  • Then add a remote for the original repo `git remote add originalrepo `, and pull/fetch from that. – Mort Sep 03 '17 at 18:53