tags:

views:

64

answers:

3

I got this message from Git:

You asked to pull from the remote 'origin', but did not specify a branch. Because this is not the default configured remote for your current branch, you must specify a branch on the command line.

Can anyone explain it? and more important how to fix it?

+5  A: 

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.

p4bl0
to make it work I had to checkout "master" branch (there was no branch selected) and pull, that fixed the problem.
cinek
@cinek: Yes, `git pull` pulls and merges with the *current branch* so its behavior completely depends on what branch is checked out, and with a detached HEAD (no branch checked out), there's no way it can know what branch to pull.
Jefromi
@cinek: I supposed you were new to git so I admit that you were in a totally standard state on branch master, my bad :-).
p4bl0
+1  A: 

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.

Tomek Szpakowicz
+1  A: 

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.7 or newer):

git branch --set-upstream origin origin/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.

On older Git versions, it’s more tedious to do this:

git config branch.master.remote origin
git config branch.master.merge refs/heads/master
Aristotle Pagaltzis