Git: setting your upstream default
August 24th, 2008
I recently set up a new repository on github. Creating the repository on github yields a page of instructions covering the two common scenarios: new and existing repositories. After following the new repository instructions, I had a repository on github, a local repository, and the following in response to my git pull command:
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 <repository> <refspec>'). 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.
Not exactly what I wanted, and certainly not what I expected. What I expected was a local repository with the upstream for master to be set to point at master on the github repository.
Setting this up can be done easily in two similar ways:
- You can edit the configuration file as directed by the error message
- You can use
git config
I opted for git config as it was easier and required no thinking—the commands are always the same1; here they are:
% git config branch.master.remote origin
% git config branch.master.merge refs/heads/master
1 For the scenario of a local empty repository pushed up to a remote, where the remote will be the upstream master.
Patching with git
March 27th, 2008
I patched the Ruby on Rails bundle for TextMate to allow footnotes to catch Haml views, which might be in files named something.haml or something.html.haml.
The change itself is trivial; making a patch using git was something new and, as it turns out, five steps:
1. Grab the source with git
Wonderland$ git clone git://github.com/drnic/ruby-on-rails-tmbundle.git
2. Make your changes
3. Commit locally, from the root of the source treee
Wonderland$ git commit -a -m 'add support for html.haml templates' Wonderland$ git show
4. Generate a patch file
Wonderland$ git format-patch origin