Set a Default Push Remote with git

By  on  

During my early days of git usage, my config allowed me to simply type git push instead of git push {origin} {branch_name} which I need to now.  Up until recently I needed to type out the long version...(I know)...which was incredibly annoying because I like using detailed branch names.

I'd finally had enough of the copy and paste branch name madness and decided I wanted git push to always push to my origin and the same branch name:

git config --global push.default current

There are a number of push.default values you can use but in most cases, especially when you have a GitHub workflow, current is likely the value you want to use.  Also, since we're using --global, this will be the default for all repositories!

Recent Features

  • By
    Facebook Open Graph META Tags

    It's no secret that Facebook has become a major traffic driver for all types of websites.  Nowadays even large corporations steer consumers toward their Facebook pages instead of the corporate websites directly.  And of course there are Facebook "Like" and "Recommend" widgets on every website.  One...

  • By
    JavaScript Promise API

    While synchronous code is easier to follow and debug, async is generally better for performance and flexibility. Why "hold up the show" when you can trigger numerous requests at once and then handle them when each is ready?  Promises are becoming a big part of the JavaScript world...

Incredible Demos

  • By
    Introducing MooTools HeatMap

    It's often interesting to think about where on a given element, whether it be the page, an image, or a static DIV, your users are clicking.  With that curiosity in mind, I've created HeatMap: a MooTools class that allows you to detect, load, save, and...

  • By
    Introducing MooTools LazyLoad

    Once concept I'm very fond of is lazy loading. Lazy loading defers the loading of resources (usually images) until they are needed. Why load stuff you never need if you can prevent it, right? I've created LazyLoad, a customizable MooTools plugin that...

Discussion

  1. Toby Griffiths

    Thanks for sharing, David. That’ll save me considerable time.

  2. Love this one ! Thank you for sharing.

    For anyone who doesn’t want to set it local, you can also do git push origin –set-upstream per your local branches: https://git-scm.com/book/en/v2/Git-Branching-Remote-Branches

  3. How do you set the default for pull? For an open source fork I have, I want git pull to default to git pull upstream special-dev-branch?

  4. Stephen Boesch

    I’d second Devin Rhode’s question

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!