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

  • Home
  • SEARCH
  • 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 5934345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:06:03+00:00 2026-05-22T15:06:03+00:00

I create a new branch in Git: git branch my_branch Push it: git push

  • 0

I create a new branch in Git:

git branch my_branch

Push it:

git push origin my_branch

Now say someone made some changes on the server and I want to pull from origin/my_branch. I do:

git pull

But I get:

You asked me to pull without telling me which branch you
want to merge with, and 'branch.my_branch.merge' in
your configuration file does not tell me, either. Please
specify which branch you want to use 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
use something like the following in your configuration file:

    [branch "my_branch"]
    remote = <nickname>
    merge = <remote-ref>

    [remote "<nickname>"]
    url = <url>
    fetch = <refspec>

See git-config(1) for details.

I learned that I can make it work with:

git branch --set-upstream my_branch origin/my_branch

But why do I need to do this for every branch I create? Isn’t it obvious that if I push my_branch into origin/my_branch, then I would want to pull origin/my_branch into my_branch? How can I make this the default behavior?

  • 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-22T15:06:04+00:00Added an answer on May 22, 2026 at 3:06 pm

    Git v2.37.1 and above

    If you are using the mentioned version or above you can use this new config entry to automatically setup remote tracking:

    git config --global push.autoSetupRemote true

    After that, when you do git push tracking is setup automatically. No need for git push -u origin my_branch


    A shortcut, which doesn’t depend on remembering the syntax for git branch --set-upstream 1 is to do:

    git push -u origin my_branch
    

    … the first time that you push that branch. Or, to push to the current branch from a branch of the same name (handy for an alias):

    git push -u origin HEAD
    

    You only need to use -u once, and that sets up the association between your branch and the one at origin in the same way as git branch --set-upstream does.

    Personally, I think it’s a good thing to have to set up that association between your branch and one on the remote explicitly. It’s just a shame that the rules are different for git push and git pull.


    1 It may sound silly, but I very frequently forget to specify the current branch, assuming that’s the default – it’s not, and the results are most confusing.

    Update 2012-10-11: Apparently I’m not the only person who found it easy to get wrong! Thanks to VonC for pointing out that git 1.8.0 introduces the more obvious git branch --set-upstream-to, which can be used as follows, if you’re on the branch my_branch:

    git branch --set-upstream-to origin/my_branch
    

    … or with the short option:

    git branch -u origin/my_branch
    

    This change, and its reasoning, is described in the release notes for git 1.8.0, release candidate 1:

    It was tempting to say git branch --set-upstream origin/master, but that tells Git to arrange the local branch origin/master to integrate with the currently checked out branch, which is highly unlikely to be what the user meant. The option is deprecated; use the new --set-upstream-to (with a short-and-sweet -u) option instead.

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

Sidebar

Related Questions

My usual workflow with git is to create a new feature branch, do some
Our policy when delivering a new version is to create a branch in our
I'm using Visual Basic 9 (VS2008) I want to create new Tabs as and
Possible Duplicate: git push error '[remote rejected] master -> master (branch is currently checked
Rails 3.0.0, Passenger 2.2.15: Create a new Rails project Add gem 'paperclip', :git =>
I performed some modifications on a branch (A). I then decided to create a
So I created a new branch in git by doing the following: git checkout
I create new ASP.NET web application that use SMTP to send message. The problem
How to create new PCL file similar to existing MS doc. I have MS
I am attempting to create new membership users in an Ektron CMS400.NET-based website by

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.