Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7034703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:13:05+00:00 2026-05-28T01:13:05+00:00

I have the remote origin set as the default branch for my current branch.

  • 0

I have the remote origin set as the default branch for my current branch. I also have an upstream remote which is not the default for the branch. Is there a way to configure a default branch on the remote so when I pull it defaults to that branch?

Here is my .git/config:

[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = git@github.com:studgeek/knockout.git
[branch "gh-pages"]
        remote = origin
        merge = refs/heads/gh-pages
[remote "upstream"]
        url = git://github.com/SteveSanderson/knockout.git
        fetch = +refs/heads/*:refs/remotes/upstream/*
        merge = refs/heads/gh-pages

With this I can happily do the following and it defaults to origin/gh-pages

git pull

What I would like to do is just give it the remote upstream and have it figure out the branch (gh-pages) part so

git pull upstream

rather than this

git pull upstream gh-pages

Right now I get the following if I omit the branch:

$ git pull upstream
You asked to pull from the remote 'upstream', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.

I can see three different ways of defaulting that would work for me in my current situations, but I’m not sure how to do any of them :):
* Just use the current branch as the default on the remote upstream
* Indicate a default branch for the upstream remote for the current branch (while leaving origin the default branch)
* Indicate a default branch on the remote. The danger here of course if I switch branches the default upstream branch stays the same. In my case that would be fine, but I can see that burning folks who didn’t expect it.

Note specifying git branch for remote asks a similar question, but the solution requires doing one of two things we don’t want to do – changing the default remote or explicitly listing the branch (we want this codified to avoid manual error).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:13:05+00:00Added an answer on May 28, 2026 at 1:13 am

    In the .git/config, you can supply the information. Example if you are in branch foo and you want to pull remotely from moo

    [branch "foo"]
       remote = origin
       merge = refs/heads/moo
    

    Next time you run git pull in branch foo, it will pull from moo.

    This has been covered in stackoverflow => How do you get git to always pull from a specific branch?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have commits that are in a remote repository (origin/master) which i want to
I have a local branch tracking the remote/master branch. After running git-pull and git-log
I have a remote actor (client) which is registering with another remote actor (server)
I have a remote monotone repos I want to pull from, but I really
I have a remote embedded system which it is telnet-able. How can I download
I have a remote tracking branch tracked locally in my local repository using 'git
I have tried following how-set-up-your-own-private-git-server-linux and private-remote-git-repositories-ubuntu-linode but I am still having problems. My
If I have 10 branches locally, how to push them to remote origin server?
I have jenkins set up to build any branch and merge it into master.
Say you have a branch on your origin that has a ridiculously long name...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.