Smitha
Smitha

Reputation: 6134

How do I update the fork when the remote repo changes?

I forked and then cloned a repo (say xyz).

Then xyz got updated and I don't have the updates in my fork.

To get them I tried the following:

 git remote add upstream xyz(ssh).

Then, git fetch upstream. Until this everything seemed fine. Now when I run -

git checkout master 

I get the error:

pathspec 'master' did not match any file(s) known to git.

I tried -

git update-ref HEAD master and got fatal: master: not a valid SHA1.

Again,

 git checkout xyz also gives error:error: pathspec xyz.git' did not match any file(s) known to git.

So, how do I keep my fork synced with remote repo and also update the local?

Upvotes: 2

Views: 154

Answers (1)

Ionică Bizău
Ionică Bizău

Reputation: 113365

Just git pull from the source repository:

cd path/to/my/fork
git pull https://github.com/user/source-repository master

That will pull and merge the changes from the source repository into your fork.

Replace master with the source branch you want to pull from. Also, you can use any type of repository url. In the example I used https.


From your question and comments I understand you have a remote named upstream and a branch named develop. So to merge upstream develop into your fork, do:

git merge upstream develop

Upvotes: 1

Related Questions