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 6668583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:03:25+00:00 2026-05-26T03:03:25+00:00

Question What’s the difference between: $ git remote add origin git@github.com:yourname/yourproject.git $ git config

  • 0

Question

What’s the difference between:

$ git remote add origin git@github.com:yourname/yourproject.git
$ git config remote.origin.push refs/heads/master:refs/heads/master
$ git push

and:

$ git remote add origin git@github.com:yourname/yourproject.git
$ git push origin master -u

Is the second version simply newer and shorter than the first version, or are there other differences?

Background Research

As of Git 1.7.0, you can use the --set-upstream option with git push. According to the git push manual:

-u, --set-upstream
    For every branch that is up to date or successfully pushed, add upstream
    (tracking) reference, used by argument-less git-pull(1) and other commands. For
    more information, see branch.<name>.merge in git-config(1).
  • 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-26T03:03:26+00:00Added an answer on May 26, 2026 at 3:03 am

    No, these are very different. The first config setting, remote.<name>.push sets a default refspec for pushing if no other refspec is specified. By default, doing git push origin will push every branch to a branch with a matching name so long as a branch with that name already existed on the remote. After doing:

    git config remote.origin.push refs/heads/master:refs/heads/master
    

    … you will find that git push origin will just push master to master.

    The other command you quote, git push -u origin master, sets two different config options if the push is successful:

    • branch.master.remote is set to origin
    • branch.master.merge is set to refs/heads/master

    These essentially say that master in origin should be regarded as the default “upstream” branch of your master branch. Their most obvious effect is to provide a default action for git pull when you are on master, but are also used in a variety of other situations, such as providing the helpful message at the top of git status that tells you where master is compared to origin/master. These settings are not, however, used to inform the default action of git push and git push origin unless you have also set the config option push.default to tracking (or upstream in recent versions).

    So, as a very approximate summary, setting remote.<name>.push affects the default action of git push, while git push -u origin master sets config options that usually just affect the action of git pull.

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

Sidebar

Related Questions

Question What is the (non-trivial) difference between the following two x86 instructions? 39 /r
QUESTION: Authenticating Drupal Users Using Remote Call to Active Directory Single-Sign-On(SSO), How do I
Question as stated in the title.
Question is pretty self explanitory. I want to do a simple find and replace,
Question Alright, I'm confused by all the buzzwords and press release bingo going on.
Question in the title. And what happens when all 3 of $_GET[foo] , $_POST[foo]
Question Can I build a image database/library that has an e-commerce style checkout system
Question says it all, really. My application is a time tracker. It's currently written
Question Using XSLT 1.0, given a string with arbitrary characters how can I get
Question: ((lambda (x y) (x y)) (lambda (x) (* x x)) (* 3 3))

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.