How to pull only one branch from remote?

How can I configure a default remote branch for when I git pull?

  • When I do `git pull`, I see this 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 specify 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. 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.

  • Answer:

    You can do this with a single command: git branch --set-upstream master origin/master

Pirkka Esko at Quora Visit the source

Was this solution helpful to you?

Other answers

In your .git/config file, you need to add a default branch for the remote repository you are are pulling from. In my case, the relevant section of my config looks like this: [branch "master"]         remote = origin         merge = refs/heads/master

Charlie Cheever

when you are pushing, you can set what it tracks by doing:         git push -u <remote> <branch> to checkout a branch and have it track that remote branch:     git checkout -t <remote>/<branch>

Joseph Hsu

You can make the config changes recommended by the error message from teh command line with...    git config branch.<local-nickname>.remote <remote-nickname>    git config branch.<local-nickname>.merge <remote-refspec>    git config remote.<nickname>.url = <remote-url>    git config remote.<nickname>.fetch = <refspec> For your particular error message, this might work:    git config branch.master.remote origin    git config branch.master.merge master You may also need to set up your remote nickname for origin:    git remote add origin git://<your-repo-URL-here> And the default remote branch to merge with your local master branch (but I think this is usually the default).    git config remote.master.fetch master

Hobson Lane

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.