
You should never 2 use git pull anyway, but if you do, git pull uses the upstream setting to figure out which remote to fetch from, and then which branch to merge or rebase with. So it shortens the use of these two commands. If you run git merge or git rebase with no additional arguments, Git uses the current branch's upstream.

(If the upstream is not set or is a local branch, Git tries fetching origin.) The upstream affects git merge and git rebase too If the upstream is a remote-tracking branch, Git fetches from that remote. If you run git fetch with no additional arguments, Git figures out which remote to fetch from by consulting the current branch's upstream. (All of this assumes your Git version is at least 2.0.) The upstream affects git fetch If your fault is set to nothing, matching, or current, setting an upstream does nothing at all for git push. But that's fairly significant, since git push is one of the places where a simple typo causes major headaches. That's it-that's all it does for git push. If your fault is set to simple or upstream, the upstream setting will make git push, used with no additional arguments, just work. A few commands, like git branch -vv, will show the upstream setting but mark it as "gone". If it does not work-if it complains that U does not exist-then most of Git acts as though the upstream is not set at all. That is, if the current branch B has upstream U, git rev-parse U should work. The upstream should, but does not have to be, a valid branch (whether remote-tracking like origin/ B or local like master). No branch can have more than one upstream.

That is, every branch either has an upstream, or does not have an upstream.

What is an upstream?Īn upstream is simply another branch name, usually a remote-tracking branch, associated with a (regular, local) branch.Įvery branch has the option of having one (1) upstream set. Precisely which version of Git you have, and what if anything you have fault set to, does matter, due to that long and boring history, but in the end, the fact that you're getting yet another complaint from Git indicates that your Git is configured to avoid one of the mistakes from the past. My guess is that you are using Git version 2-point-something, and that you have set fault to simple to get it to shut up. You do not mention which version of Git you are running, nor whether you have configured fault, so we must guess. For several versions of Git before and after 2.0, every time you ran git push, Git would spew lots of noise trying to convince you to set fault just to get git push to shut up. 1 As of Git version 2.0, Git now has a configuration knob spelled fault which now defaults to simple. To shorten it a whole lot, git push was implemented poorly. The complete push story here is long and boring and goes back in history to before Git version 1.5. If you do not have upstream for the current branch, however, Git changes its behavior on git push, and on other commands as well. The answer to the question you asked-which I'll rephrase a bit as "do I have to set an upstream"-is: no, you don't have to set an upstream at all. TL DR: git branch -set-upstream-to origin/solaris The branch clearly exists, so it was created and pushed: $ git branch -a

Or, it's another instance of Git taking a simple task and making it difficult. I'm guessing it's another instance of an incomplete or wrong accepted answer. I followed this question and answer on Stack Overflow: Push a new local branch to a remote Git repository and track it too. Is there any reasonable use case where someone would create, push the to remote, and then claim a commit on is not supposed to be for ? Why do I have to do something special for this? To push the current branch and set the remote as upstream, use Add workaround for missing _mm_set_epi64xįatal: The current branch solaris has no upstream branch. After committing a change and attempting to push the changes: $ git commit blake2.cpp -m "Add workaround for missing _mm_set_epi64x" I created a local branch for testing Solaris and Sun Studio.
