Setting upstream with Git
Setting the upstream location for git means that you can simply type
git fetch or
git push and have the server automatically fetch or push to that upstream location.
Imagine a situation where you clone a git repository using
git clone, and you want to add an upstream so you can both pull and push from that remote git repository. The easiest way to do this is by using git push like this:
# remote is your remote, usually origin # branch is the branch you are on, usually master # -u means to save the settings for future git push -u [remote] [branch]
If your remote is not called origin, you can find a list of your remote's name by running the following
git remote -v
Which will usually return something like this, where 'origin' below is the name of the remote repo:
If you have no remote repos set up, you can set one up by doing the following, and then doing
origin email@example.com:user/repo.git (fetch) origin firstname.lastname@example.org:user/repo.git (push)
git push -u [remote] [branch]to set the default upstream location.
# replace email@example.com:user/repo.git with your repo. git remote add firstname.lastname@example.org:user/repo.git
git push -u <remote><branch> isn't working for you, you can also set the upstream by doing this
# remote is your remote, usually origin # branch is the branch you are on, usually master git push --set-upstream [[remote]] [branch]