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
    CSS vs. JS Animation: Which is Faster?

    How is it possible that JavaScript-based animation has secretly always been as fast — or faster — than CSS transitions? And, how is it possible that Adobe and Google consistently release media-rich mobile sites that rival the performance of native apps? This article serves as a point-by-point...

  • By
    5 HTML5 APIs You Didn’t Know Existed

    When you say or read "HTML5", you half expect exotic dancers and unicorns to walk into the room to the tune of "I'm Sexy and I Know It."  Can you blame us though?  We watched the fundamental APIs stagnate for so long that a basic feature...

Incredible Demos

  • By
    MooTools Zebra Tables Plugin

    Tabular data can oftentimes be boring, but it doesn't need to look that way! With a small MooTools class, I can make tabular data extremely easy to read by implementing "zebra" tables -- tables with alternating row background colors. The CSS The above CSS is extremely basic.

  • By
    Create Custom Events in MooTools 1.2

    Javascript has a number of native events like "mouseover," "mouseout", "click", and so on. What if you want to create your own events though? Creating events using MooTools is as easy as it gets. The MooTools JavaScript What's great about creating custom events in MooTools is...

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!