3

Is there a way to configure git to default push my current branch to the origin?

E.g., I want to do:

git push origin

And have it push whatever branch I've currently checked out to the upstream origin.

MrDuk
  • 16,578
  • 18
  • 74
  • 133
  • Did you try Google? http://stackoverflow.com/questions/948354/git-push-current-branch – Graham Jun 05 '13 at 19:41
  • I did, and saw the post you linked. I'm confused on what's considered 'upstream' though. Is that the branch I've branched off of, or is that the true 'upstream repo'? – MrDuk Jun 05 '13 at 19:50
  • `upstream` pushes "the current branch to **its** upstream branch", i.e. the upstream tracking branch. `current` does something similar but assumes the upstream branch has the same name as the current one. There's a good explanation here http://stackoverflow.com/questions/11872984/what-is-the-difference-between-git-push-default-current-and-push-default-upstrea – Graham Jun 05 '13 at 19:57
  • So I did: git push -u origin mybranch ... but I think that's not what I want. Is there a way to undo that? When I set the push config, and tried to do git push it just said 'branch has no upstream branch'. – MrDuk Jun 06 '13 at 12:59

1 Answers1

1

Set push.default to tracking.

$ git config --global push.default tracking

Now git push pushes only the branch you're currently on, assume an upstream branch has been configured (see git branch --set-upstream).

user229044
  • 232,980
  • 40
  • 330
  • 338