Pivotal Labs

Main menu

Skip to primary content
Skip to secondary content
  • About
  • Case Studies
  • Team
    • Executives
    • Locations
      • San Francisco (HQ)
      • Boston
      • Boulder
      • Denver
      • London
      • Los Angeles
      • New York
  • Community
    • Blogs
    • Tech Talks
    • Events
  • Careers
    • Lifestyle
    • Principles & Practices
    • Benefits
    • FAQ
    • Apply
  • Contact
    • Press Room
    • Press Releases
    • In The News
    • Press Kit
  • All
  • Labs
  • Standup
  • Tracker

git config push.default matching

Alex Chaffee
Thursday, June 4, 2009

Upgraded to git 1.6.3 yet? You should, and Jason Rudolph says why (and if you’re on a Mac, Rob Sanheim says how.)

Sadly, after you do upgrade, when you start doing “git push”, your console will start to be littered with the following oddly patronizing message:

warning: You did not specify any refspecs to push, and the current remote
warning: has not configured any push refspecs. The default action in this
warning: case is to push all matching refspecs, that is, all branches
warning: that exist both locally and remotely will be updated.  This may
warning: not necessarily be what you want to happen.
warning:
warning: You can specify what action you want to take in this case, and
warning: avoid seeing this message again, by configuring 'push.default' to:
warning:   'nothing'  : Do not push anything
warning:   'matching' : Push all matching branches (default)
warning:   'tracking' : Push the current branch to whatever it is tracking
warning:   'current'  : Push the current branch

While I’m generally in favor of verbose warnings, this one is kind of bizarre. Essentially, it’s saying, “Warning! The command you just ran will continue to operate exactly as it did before!” Guys, telling us about new options is great but that’s what release notes are for.

Worse, they don’t provide keystroke-level instruction beyond the offhand gerund “configuring” on how to shush it. Here’s the result of my 8-minute speluking inside the output of “git help config”:

git config push.default matching

[Or, thanks to Alastair Brunton below

git config --global push.default matching

]

There, now, that wasn’t so hard after all, was it?

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

19 Comments

  1. Jack Dempsey says:

    Alex,

    I recently went through the same change, but decided to go with current instead of matching. With current I know its only the branch I’m on that’s getting pushed, rather than possibly a bunch of other branches that may not be ready. Given how easy it is to switch to branches and then git push, I feel its worth the couple seconds extra effort.

    jack

    June 4, 2009 at 5:52 pm

  2. Alex Chaffee says:

    OK, fair enough. “git config push.default current” might be a good way to shush the ebullient warning.

    June 5, 2009 at 3:35 am

  3. bryanl says:

    I just saw that error as well. I had assumed I had borked my git setup, but I did change it current just like Jack.

    June 5, 2009 at 9:21 pm

  4. Alastair Brunton says:

    Also if you have lots of repositories, you can add this to the global config with:

    “git config –global push.default matching”

    (or with one of the other push defaults)

    July 2, 2009 at 1:21 am

  5. Alex Chaffee says:

    Thanks, Alastair!

    July 2, 2009 at 7:19 am

  6. Adam Bair says:

    Thanks Alex (and Alastair) – just ran into this as well. +1 to Jack and Bryan for “current”

    July 6, 2009 at 10:12 pm

  7. Johann says:

    Thanks a lot guys!

    July 12, 2009 at 2:27 am

  8. Jirapong Nanta says:

    Thanks.

    July 17, 2009 at 1:16 am

  9. Phil says:

    Adding my thanks: Thanks!

    July 18, 2009 at 12:37 pm

  10. Mitch says:

    So what is the difference between “tracking” and “current”?

    Where does “current” push to?

    August 20, 2009 at 2:26 pm

  11. Alex Chaffee says:

    Mitch — Um… uh… I have no idea.

    September 2, 2009 at 3:16 pm

  12. Jamie Flournoy says:

    >So what is the difference between “tracking” and “current”?

    From ‘man git-config’:

    nothing: do not push anything.

    matching: push all matching branches. All branches having the same name in both ends are considered to be matching. This is the default.

    tracking: push the current branch to its upstream branch.

    current: push the current branch to a branch of the same name.

    see also: http://www.kernel.org/pub/software/scm/git/docs/git-config.html#_variables

    September 9, 2009 at 11:48 am

  13. Alex Chaffee says:

    Thanks, Jamie.

    So when does the upstream branch not have the same name?

    September 9, 2009 at 12:02 pm

  14. Joseph Palermo says:

    When you create your local branch with a different name? (don’t do that)

    September 9, 2009 at 1:51 pm

  15. Josh Susser says:

    @Joseph: I create local branches with names that are different from the remote name if I’m using multiple remotes. That’s required if the remote branches have the same name within their respective repos. Why is that bad to do?

    September 10, 2009 at 8:02 am

  16. Joseph Palermo says:

    It’s bad because I’ve never done that.

    Move along… move along…

    September 10, 2009 at 4:04 pm

  17. dilip says:

    thanks it helped!

    September 13, 2009 at 8:34 am

  18. David T says:

    Thanks for taking the time to do this post. It was really bugging me.

    September 17, 2009 at 3:45 am

  19. Jack Repenning says:

    Somewhere along the lines since this discussion, the available options for push.default have changed, so I thought I ‘d update this thread with the latest (1.8) possibilities:

    git config push.default:
    – nothing: do nothing (make the user say what they mean)
    – matching: push all local branches for which a remote branch of the same name exists
    – upstream: push only the current branch, push it to its upstream, making push and pull symmetric
    – simple: like upstream, but only if the branch names match (will become default in 2.0)
    – current: push just the current branch

    March 18, 2013 at 1:06 pm

Add New Comment Cancel reply

Your email address will not be published.

Alex Chaffee

Recent Posts

  • Code Monkey
  • RubyGems Warningitis Outbreak
  • Upgrading your Rakefile from RSpec 1.3 to RSpec 2
Subscribe to Alex's Feed

Author Topics

ruby (14)
gem (5)
ruby on rails (24)
erector (2)
rspec (4)
activerecord (4)
database (3)
sinatra (1)
postgresql (1)
css (1)
html (1)
git (2)
mac (5)
java (3)
agile (12)
iphone (1)
migrations (1)
fun (5)
dot (1)
graphing (1)
subversion (1)
test (1)
demeter (1)
puzzler (1)
  • About
  • Case Studies
  • Team
  • Community
  • Careers
  • Contact
  • Labs
  • Events

Contact Us

contact@pivotallabs.com
+1 415-77-PIVOT
TwitterLinkedInFacebook

Pivotal Tracker

Tracker is the award-winning agile project management tool that enables real-time collaboration around a shared, prioritized backlog.
Visit pivotaltracker.com >