Git

Upstream vs Origin

origin by default is the remote when you clone a repo, so if the repo is just a normal repo without being forked, we have only origin remote. If the repo is forked off from another repo, then we have another remote upstream which points to the original repo that our repo is forked from.

You can see all the remotes with their address using the following command:

git remote -v

Rename remote

git remote rename origin soheil

Sync your fork with upstream

Once you're in you main branch in your own fork, run the following command:

git fetch upstream
git rebase upstream/main

Add remote

If you want to work on someone else's fork, you can add their remote:

git remote add soheil git:soheil@github.com/repo.git
git fetch soheil
git checkout soheil/main

Diff between your branch and upstream

git diff upstream/main...HEAD