GIT–How to sync your fork with upstream?

Damir Dobric Posts

Next talks:

 

    

Follow me on Twitter: #ddobric



 

 

Archives

After you have created a ‘fork’, you might need to sync it with the original repository. This original (NOT origin) repository is called upstream.

To do a sync you open command prompt of the cloned local repository of your fork and execute following command:

git fetch upstream

Unfortunately this might fail with following error:

Please make sure you have the correct access rights and the repository exists.

This happen if your local repository has not set upstream. To check the upstream execute following command:

git remote -v

this will return following response, which means that the upstream URL is missing.

origin  https://github.com/daenetCorporation/Logging.git (fetch)
origin  https://github.com/daenetCorporation/Logging.git (push)

To set the upstream navigate to the upstream (original) repository from where the fork was created and grab the url of the repo.

git remote set-url origin https://github.com/daenetCorporation/Logging.git

To get in sync with th eupstream execute following:

git fetch upstream

Please note that if you have set URL of the for example ‘dev’ branch, then you don’t need to execute following, because it will fail:

git fetch upstream/dev

After all, you will get in Visual Studio additional upstream branch.

image


Posted Apr 26 2017, 08:29 AM by Damir Dobric
Filed under: , ,
developers.de is a .Net Community Blog powered by daenet GmbH.