Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Why are all local branches pushed by default?
Why are all local branches pushed by default? [message #716471] Wed, 17 August 2011 14:04 Go to next message
Dominik Schadow is currently offline Dominik SchadowFriend
Messages: 15
Registered: July 2009
Junior Member
When I e.g. clone a Git repository from GitHub, create a local branch, do some work (add, commit, merge), do not delete the local branch, and push my changes, my formerly local branch is pushed to my GitHub repository. Sure, the Configure push dialog tells me, 'All branches will be pushed using Push Spec "refs/head/*:refs/heads/*"'. But why is this the default? With Git on the command line, a new local branch is not pushed by default; I'll have to do that explicitly.

With EGit, all branches of all developers pushing to this repository are shared, which isn't my intention. And the only solution I'm aware of is for every developer, to update his configuration to only push from local master to remote master. This configuration work seems unnecessary to me, since the Git workflow recommends creating a branch for all changes first, and only push from master. And not all local branches can/ should be deleted right away after merging the changes.

I'm using Eclipse 3.7 with EGit 1.0.

Thanks, Dominik

[Updated on: Wed, 17 August 2011 14:05]

Report message to a moderator

Re: Why are all local branches pushed by default? [message #716493 is a reply to message #716471] Wed, 17 August 2011 14:55 Go to previous messageGo to next message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1072
Registered: July 2009
Senior Member
I think we did that since the native git reference documentation states that this is the default.
See option "<refspec>..." in section "Options" in
http://kernel.org/pub/software/scm/git/docs/git-push.html :

"The special refspec : (or +: to allow non-fast-forward updates) directs git to push "matching" branches: for every branch that exists on the local side, the remote side is updated if a branch of the same name already exists on the remote side. This is the default operation mode if no explicit refspec is found (that is neither on the command line nor in any Push line of the corresponding remotes file---see below)."
Re: Why are all local branches pushed by default? [message #716515 is a reply to message #716493] Wed, 17 August 2011 15:28 Go to previous messageGo to next message
Dominik Schadow is currently offline Dominik SchadowFriend
Messages: 15
Registered: July 2009
Junior Member
OK, thanks for your reply. I've compared the EGit behavior to msysGit today, not the original reference.

From a normal (hopefully Wink) developers' standpoint, an "only push master by default, everything else must be selected explicitly" behavior makes more sense to me. Since the normal Git workflow is to create a (short living local) branch for every change, publishing those branches by default is unnecessary. And why bother everybody with such configuration work?

Am I the first one bringing this up? Sure, you have followed the original implementation, but what's about the users out there? OK, such a poll might end up 50:50.

Regards, Dominik
(no subject) [message #716601 is a reply to message #716493] Wed, 17 August 2011 19:33 Go to previous messageGo to next message
Carsten Reckord is currently offline Carsten ReckordFriend
Messages: 139
Registered: July 2009
Senior Member
On 17.08.2011 16:55, Matthias Sohn wrote:
> I think we did that since the native git reference documentation states that this is the default.
> See option "<refspec>..." in section "Options" in
> http://kernel.org/pub/software/scm/git/docs/git-push.html :
>
> "The special refspec : (or +: to allow non-fast-forward updates) directs git to push "matching" branches: for every branch that exists on the local side, the remote side is updated if a branch of the same name already exists on the remote side. This is the default operation mode if no explicit refspec is found (that is neither on the command line nor in any Push line of the corresponding remotes file---see below)."

But that behavior is very different from pushing _all_ local branches to
remote. It only pushes those that already exist in the remote - which, if I
understand correctly, is a lot closer to what Dominik would prefer.
Re: (no subject) [message #716785 is a reply to message #716601] Thu, 18 August 2011 13:19 Go to previous messageGo to next message
Dominik Schadow is currently offline Dominik SchadowFriend
Messages: 15
Registered: July 2009
Junior Member
Oh yes, that's correct Carsten. Did not notice that. It's totally OK to push all branches from local to remote which are already available remote automatically. However, automatically pushing branches, that are only available locally, is not what I expect, but EGit does. This is the behavior that disturbs me.
Re: (no subject) [message #716920 is a reply to message #716785] Thu, 18 August 2011 19:20 Go to previous messageGo to next message
Manuel Doninger is currently offline Manuel DoningerFriend
Messages: 119
Registered: October 2010
Senior Member
Which branch do you use as source, when creating a local branch? If you use a remote tracking branch (e.g. origin/master), then EGit pushes your local branch, because the branch is connected with an upstream branch, the remote tracking branch, from which you created the local branch. If you use a local branch as source (e.g. master), then EGit doesn't push your local created branch. So EGit doesn't push all branches, but all branches with an upstream branch (the upstream branch doesn't have necessarily the same name as the local branch)

[Updated on: Thu, 18 August 2011 19:24]

Report message to a moderator

Re: (no subject) [message #716975 is a reply to message #716785] Thu, 18 August 2011 23:20 Go to previous messageGo to next message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1072
Registered: July 2009
Senior Member
Ok, you are right, we missed this condition hence EGit doesn't follow the canonical reference here, please post your finding on https://bugs.eclipse.org/bugs/show_bug.cgi?id=352381 to point out how EGit deviates from the reference.
Re: (no subject) [message #717036 is a reply to message #716975] Fri, 19 August 2011 06:41 Go to previous messageGo to next message
Dominik Schadow is currently offline Dominik SchadowFriend
Messages: 15
Registered: July 2009
Junior Member
Done, I missed this bug before.

Local/ remote branches: I just verified this again: created a branch on a remote and a local (wizard warning about this fact) branch. Both were pushed, doesn't make a difference.
Re: (no subject) [message #717037 is a reply to message #717036] Fri, 19 August 2011 06:45 Go to previous messageGo to next message
Manuel Doninger is currently offline Manuel DoningerFriend
Messages: 119
Registered: October 2010
Senior Member
Which version of EGit do you use? I tried that yesterday, and the local branch which i created from another local branch didn't got pushed. I have the nightly build of EGit.
Re: (no subject) [message #717073 is a reply to message #717037] Fri, 19 August 2011 08:20 Go to previous messageGo to next message
Stefan Lay is currently offline Stefan LayFriend
Messages: 342
Registered: July 2009
Senior Member
@Dominik: Which version of EGit do you use? 1.0 behaves as you describe. Since commit c6dd679 of 2011-07-06 EGit should only push the currently checked out branch, and that only if it finds a corresponding remote in the configuration. If you do not base your local branch on a remote tracking branch, the default remote "origin" will be taken. I f you do not have a remote called "origin", nothing will be pushed.

@Manuel: How did you push? With "Push to Upstream" my local branch got pushed even though I had created it from another local branch. How does your configuration look like?
Re: (no subject) [message #717117 is a reply to message #717073] Fri, 19 August 2011 11:04 Go to previous messageGo to next message
Manuel Doninger is currently offline Manuel DoningerFriend
Messages: 119
Registered: October 2010
Senior Member
Stefan: I used Push to Upstream and only the branch which i created from a remote tracking branch was pushed. I'll post my config later, when i'm at home.
Re: (no subject) [message #718191 is a reply to message #717073] Tue, 23 August 2011 14:49 Go to previous messageGo to next message
Dominik Schadow is currently offline Dominik SchadowFriend
Messages: 15
Registered: July 2009
Junior Member
This (miss-) behavior is already fixed in the latest EGit 1.1 builds. My experiences described above are based on EGit 1.0. I'm looking forward to EGit 1.1, a lot of work to make all team members update their local refspec...
Re: Why are all local branches pushed by default? [message #730217 is a reply to message #718191] Tue, 27 September 2011 22:45 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1720
Registered: July 2009
Senior Member
OK, today I'm a real newbie Smile I made my first push to an eclipse git repo(!) and my very first commit showed up as an unwanted branch on the server (I wasn't asked any questions).

From what I've seen today, what promises to be the easy way "Push to upstream" should actually be disabled until you've made 5 pushes and demonstrated you understand what you are doing.

For newbies like me I'd really suggest to first stick with "Team > Remote > Push", because then we have a chance to see what happens before it happens. Otherwise one will be unpleasently surprised by the effect of branching before push and it will take a long time until this person is at fully ease with branching.

Unfortunately that action is (1) burried deeper in the menu hierarchy (hidden from newbies) and (2) disabled if more than one project is selected (why?).

Actually, I've seen several situations where EGit seems to interpret multi-selections differently from what I intend to say. The other situation I can remember is: Repositories view, under Working directory select multiple projects for import, result: "Import Projects ..." is not offered, hm...

just trying to capture my confusion while it still lasts Smile
Stephan



Previous Topic:Commit on Master with JGit API?
Next Topic:EGit checkout changes file permissions
Goto Forum:
  


Current Time: Mon Aug 19 03:57:42 GMT 2019

Powered by FUDForum. Page generated in 0.03227 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top