Confusing error message from git
Solution 1:
You have to tell git which branch you want to pull from the "origin" remote repos.
I guess you want the default branch (master) so git pull origin master
should fix your problem.
See git help branch
, git help pull
and git help fetch
for more informations.
Solution 2:
To fix it, assuming you are on the master
branch and want to pull the master
branch from the origin
remote, in new enough Git versions (1.8 or newer):
git branch -u origin/master master
(Analogously for other branches and/or remotes.)
If you can combine this with a push, it’s even shorter:
git push -u origin master
Thereafter, a plain git pull
/git push
will do what you expect.
During the Git 1.7 series, git branch
didn’t have the -u
switch (only git push
did), and instead you had to use the much longer --set-upstream
:
git branch --set-upstream master origin/master
Note the reversal of arguments compared to -u
. I fumbled this order more than once.
All of these, by the way, are shorthands for doing the following, which you can still do explicitly:
git config branch.master.remote origin
git config branch.master.merge refs/heads/master
Before 1.7, you had to do it this way.
Solution 3:
Message says exactly what it is about. Your current branch is not associated with (is not tracking) any branch in origin. So git doesn't know what to pull.
What to do? That depends...
In most usual situation you are working off some local branch xyz which branched from master which is cloned from origin's master. The usual way to resolve it is to switch to master and pull to synchronize it with origin and then come back to xyz and rebase master
.
But in your situation you might want to do something else. We can't know it without knowing details of your branches and remotes and how you intent to use them.