Skip to content

Instantly share code, notes, and snippets.

@lxneng
Created May 27, 2011 03:44
Show Gist options
  • Select an option

  • Save lxneng/994604 to your computer and use it in GitHub Desktop.

Select an option

Save lxneng/994604 to your computer and use it in GitHub Desktop.
How do you get git to always pull from a specific branch?

Under [branch "master"], try adding the following to the repo's Git config file (.git/config):

[branch "master"]
    remote = origin
    merge = refs/heads/master

This tells Git 2 things:

When you're on the master branch, the default remote is origin. When using git pull on the master branch, with no remote and branch specified, use the default remote (origin) and merge in the changes from the master branch. I'm not sure why this setup would've been removed from your configuration, though. You may have to follow the suggestions that other people have posted, too, but this may work (or help at least).

If you don't want to edit the config file by hand, you can use the command-line tool instead:

$ git config branch.master.remote origin
$ git config branch.master.merge refs/heads/master

Or, if you're like me, and want this to be the default across all of your projects, including those you might work on in the future, then add it as a global config setting:

$ git config --global branch.master.remote origin
$ git config --global branch.master.merge refs/heads/master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment