Usually for me this happens when I have an existing project and I setup a github repo for it. As part of the setup for the github project, it gives you the commands to run to add the github repo as a remote to my local git repo.
cd existing_git_repo
git remote add origin git@github.com:caius/foo.git
git push origin master
The problem then is you've added the remote account, but the local master branch isn't tracking the remote master branch, so when you try and just git pull it will fail with a message telling you to set the remote refs up.
Julius:foo(master) caius$ git pull
You asked me to pull without telling me which branch you
want to merge with, and 'branch.master.merge' in
your configuration file does not tell me either. Please
name which branch you want to merge on the command line and
try again (e.g. 'git pull').
See git-pull(1) for details on the refspec.If you often merge with the same branch, you may want to
configure the following variables in your configuration
file:branch.master.remote = <nickname> branch.master.merge = <remote-ref> remote.<nickname>.url = <url> remote.<nickname>.fetch = <refspec>See git-config(1) for details.
The answer is to do what it says funnily enough, and add the remote refs tracking to the config file. The easiest way I've found of doing this is to edit .git/config and add the following at the bottom of it.
[branch "master"]
remote = origin
merge = refs/heads/master
Remember to change the branch or remote names if you need to.
Once you've added that to the config you can run git pull on the master branch and it'll do the usual automagical thing and pull the remote master branch changes into the local one!
Updated 2008-11-09
See Ciarán's comment below for an all-inclusive command to do the above.
You can use
git remote add --track master origin git@github.com:caius/foo.gitAlso see
git config --global branch.autosetupmerge trueThanks for the tips. Both the author and commenter.
Thanks, useful tip for github...
And if you've already set up the origin and forgot to add the
--trackoption, then you can doWhich will replace whatever branches are already being tracked with
masterandmy_other_branch.If you just want to add a branch to track (e.g.: a new dev branch on the origin server) then do:
We do it with
git config --add branch.master.remote origin git config --add branch.master.merge refs/heads/master
which amounts to the same thing, but avoids editing .git/config directly.