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?
-u : The -u flag creates a tracking reference for every branch that you successfully push onto the remote repository. The local branch you push is automatically linked with the remote branch. This allows you to use commands such as git pull without any arguments.
git pull origin master will pull changes from the origin remote, master branch and merge them to the local checked-out branch. git pull origin/master will pull changes from the locally stored branch origin/master and merge that to the local checked-out branch.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With