Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse git pushes all branches instead of the current one only

Tags:

git

eclipse

egit

I see this for egit's Push to Upstream:

demo

It says "Push current branch."

When I use it, all branches get pushed instead of only the current one. Is there a way to configure it to push only the current branch?

like image 371
levant pied Avatar asked Aug 17 '16 16:08

levant pied


People also ask

Does git push push to all branches?

No, git push only pushes commits from current local branch to remote branch that you specified in command.

How do I switch between GIT branches in eclipse?

Right-click your project and select Team → Branch to create new branches or to switch between existing branches. You can also switch branches in the History view.

What is push to upstream in eclipse?

Push to Upstream.. pushes your branch as you would expect for a remote-tracking branch. Push... opens a dialog and lets you specify which refspecs you should push up, including tags, special cases like HEAD:refs/heads/master, etc.


1 Answers

Check your git configuration for the push policy:

git config push.default

(same as "Eclipse > Window > Preferences > Team > Git > Configuration")

It should be "simple" to be sure to only push the current branch (to an upstream branch of the same name)

On Egit, check Team -> Remote -> Configure Push to Upstream
Pushing a single branch wasn't supported in 2011, because of an old JGit bug.
The table "How compatible is EGit with Git?" does not mention push.default. Here is the current implementation of

  • JGit PushCommand.java
  • JGit PushCommand tests, which respect the refspec associated to upstream: if it is +refs/heads/*:refs/remotes/origin/*, that owuld explain why it pushes all the branches.

I usually prefer to use pushing the current branch option explicitly (instead of push to upstream)

push

like image 182
VonC Avatar answered Sep 21 '22 12:09

VonC