
It is common to use upstream as the nickname for this remote.

It makes your setup easier for others to understand and for you to transfer information that you read in documentation, on Stack Overflow, or in blogs.Ī common reason to add a second remote is when you have done a “fork and clone” of a repo and your personal copy (your fork) is set up as the origin remote.Įventually you will want to pull changes from the original repository.
GIT SET UPSTREAM PATCH
It is tempting to use a more descriptive nickname (such as github), but you might find that following convention is worth it. Heres a patch to fix the easy part: - >8 - Subject: PATCH pull: document more passthru options git pull accepts the options -dry-run, -p/-prune, -refmap, and -t/-tags since a32975f516 (pull: pass git-fetchs options to git-fetch, ), -j/-jobs since 62104ba14a (submodules: allow parallel fetching, add tests and documentation.
Sidebar on nicknames: there is a strong convention to use origin as the nickname of your main remote.Īt this point, it is common for the main remote of a repo to be hosted on GitHub (or GitLab or Bitbucket). How do you set an upstream branch in Git using the command line To set the upstream branch in Git, use the following command: git push -set-upstreamNote: when you add a remote you give it a nickname (here happygit), which you can use in git commands in place of the entire URL. Use git remote add to add a new remote: git remote add happygit However, after the initial clone, it is often useful to add additional remotes.

For example: git branch -set-upstream-to remotename/branchname git push -set-upstream By using this command you can setup tracking information for the current branch during the push.

Git clone automatically adds a new remote, so often you do not need to do A few commands, like git branch -vv, will show the upstream setting but mark it as gone. By using this command you can make an existing local branch track a specified remote branch.
