Getting started with git and github

For my latest project, I decided to bite bullet and go with git and GitHub.

It's a little disconcerting as I'm really comfortable with SVN but a good move nonetheless since that sort of comfort is rarely a good thing (there are many things I wish SVN did differently but I use it because I know it and it's not CVS!)

Setting up your project on GitHub couldn't be easier. It took me a few moments. I'd already installed git via MacPorts for something else (can't remember what) so I didn't have to do anything else.

Initially, everything went as planned.

Then, on my second clone of a remote repository, when I tried to git pull, I got the following error message:

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 = branch.master.merge = remote..url = remote..fetch =

See git-config(1) for details.

Umm, yeah, sure, sounds fab, really it does, I'll do just that...

So I looked at the .git/config file in my initial clone and saw that it had a line that the new one didn't have in it (in boldface, below).

[remote "github"]
  url = <em><my github url></em>
  fetch = +refs/heads/*:refs/remotes/github/*
  <strong>push = refs/heads/master:refs/heads/master</strong>
[branch "master"]
  remote = github
  merge = refs/heads/master

Adding the push = to the .git/config file for the other clone did the trick.

Not sure what it does or why it's necessary so if anyone can enlighten me, please do! :)

Comments