Git Getting started with Git Setting up the upstream remote

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

If you have cloned a fork (e.g. an open source project on Github) you may not have push access to the upstream repository, so you need both your fork but be able to fetch the upstream repository.

First check the remote names:

$ git remote -v
origin    https://github.com/myusername/repo.git (fetch)
origin    https://github.com/myusername/repo.git (push)
upstream  # this line may or may not be here

If upstream is there already (it is on some Git versions) you need to set the URL (currently it's empty):

$ git remote set-url upstream https://github.com/projectusername/repo.git

If the upstream is not there, or if you also want to add a friend/colleague's fork (currently they do not exist):

$ git remote add upstream https://github.com/projectusername/repo.git
$ git remote add dave https://github.com/dave/repo.git


Got any Git Question?