2
In Git 2.0 the default has been changed to simple which is narrower in scope – more specific and more intuitive – it will now only push:

The current branch to the branch with the same name only when the current branch is set to integrate with that remote branch on the same remote;

The current branch to the branch with the same name, if you are pushing to a remote that is not where you usually fetch from.

I'm confused about this. What does "the current branch is set to integrate with that remote branch" mean? I'm working on a feature branch I created locally. When I run "git push", will it push my branch to the remote?

qazwsx
  • 25,536
  • 30
  • 72
  • 106
  • possible duplicate of [Warning: push.default is unset; its implicit value is changing in Git 2.0](http://stackoverflow.com/q/13148066/3755692) – msrd0 Nov 10 '14 at 20:22
  • It means that it will only push the branch you're on, and only push it to the most intuitive place. Older versions of git would try to push a lot more branches, causing extra work to resolve. – Paul Hicks Nov 10 '14 at 20:24

1 Answers1

1

You can find documentation on push.default here

simple is intended to be the 'probably does what you want' default in newer git versions. It's a halfway-house between current and upstream.

Let's assume that you're working on a branch called foo.

current means that if you either tell git to push to the place you normally pull from (git push or git push origin), or if you tell it to push to some other remote repository (git push somewhere_else), it will push a branch called foo to a remote branch also called foo. This means that git push will be interpreted as git push origin foo:foo.

upstream means that if you tell git to push to the place you normally pull from, it will push the branch to whatever remote branch it is tracking - i.e. the branch that you get updates from when you pull. You can find this in the config file inside the repository's .git folder. For example, if it contains the section

[branch "foo"]
remote = origin
merge = refs/heads/bar

then that means that a straightforward git push when you've got branch foo checked out will push to origin/bar, so it's equivalent to git push origin foo:bar.

upstream only makes sense when you're pushing to the place you pull from. If your local branch isn't tracking an upstream branch, nothing will happen (though git will suggest a single line push-and-start-tracking command, see below).

simple does the same as upstream when you push to the place you normally pull from, and does the same as current if you're pushing somewhere else.

Now, you mentioned in your post that you're dealing with a local branch, which presumably means it's not tracking anything on the remote end. You can push a branch and make it track the place it was pushed to with the following:

git push --set-upstream origin foo:bar

Leaving out the :bar will make it push to a branch with the same name as the local branch.

Tarrenam
  • 382
  • 2
  • 11