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
    Welcome to My New Office

    My first professional web development was at a small print shop where I sat in a windowless cubical all day. I suffered that boxed in environment for almost five years before I was able to find a remote job where I worked from home. The first...

  • 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
    Fullscreen API

    As we move toward more true web applications, our JavaScript APIs are doing their best to keep up.  One very simple but useful new JavaScript API is the Fullscreen API.  The Fullscreen API provides a programmatic way to request fullscreen display from the user, and exit...

  • By
    Spatial Navigation

    Spatial navigation is the ability to navigate to focusable elements based on their position in a given space.  Spatial navigation is a must when your site or app must respond to arrow keys, a perfect example being a television with directional pad remote.  Firefox OS TV apps are simply...

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!