I've noticed that the "Automatically sync with tracked branch" feature of NetBeans git integration doesn't seem to work when doing "Fetch from Upstream". Instead the local branches go from "in-sync" to "behind" and I need to manually fast-forward each one of them.
It should sync all local branches when fetching if tracking is enabled and there is no merge involved.
Strange. It works for me correctly. I mark the branch i want to sync (Automatically sync with origin/BRANCH). Then i do Git -:> Fetch from Upstream and it's updated.
Are you sure the branch has its tracked branch and the Autosyc flag really enabled?
Also please check the IDE log for any related errors (attach it here after the fetch action).
Created attachment 150274 [details]
Full test case visually
To reproduce this in a clean room environment, I did this on my Linux machine with the 201411010002 nightly:
1) git init on a remote system, make the initial commit
2) clone the repo over ssh using NetBeans
3) enable sync for origin/master
3) add more commits remotely
4) fetch from upstream
5) master is behind origin
I couldn't attach the log here for reasons, but I hope this can be reproduced on your end like this. In the screenshot I first fetched the second commit, then tried to fetch again and it's a no-op as it should, then made more commits and fetched again. The master branch kept being on the initial commit.
I'm certain this happens on my Windows 7 machine too but again when I got the time to reply I was on a different system.
> 4) fetch from upstream
> 5) master is behind origin
That is correct of course, it works as expected. We cannot sync the current branch automatically because it requires a merge/rebase or a checkout at least (in which case your files will change right under our nose with a danger of you making changes to them in the meantime). That sync option works *only* for other (not checked-out) branches. What you want to do in this case is a git pull.
So it works as designed, but probably not as you expected. It merely works for all other branches than the currently checked-out (you can see on the screenshot that even the manual "Sync with origin/master" is disabled, that's the reason). Sorry if you expected something else.
Couldn't it do that if your working directory is clean? That's the case when I expected it to fast-forward the checked out branch when there are no changes to be committed or no commits that would need to be merged so updating the working copy wouldn't have any negative effects.
(In reply to hifi from comment #5)
> Couldn't it do that if your working directory is clean? That's the case when
> I expected it to fast-forward the checked out branch when there are no
> changes to be committed or no commits that would need to be merged so
> updating the working copy wouldn't have any negative effects.
I guess it could ask you (after a fetch) if you want to sync and make the checkout. In that case the responsibility would be up to you (as a user). Because i am not very comfortable with actually messing with user source files without user noticing or approving it. Would that be ok?
That would be much better in my opinion than leaving you "hanging" without any idea why the sync "isn't working".
So offering to fast-forward the current branch if it is by all means possible (no unsaved modifications in any editor tab for the files or saved modifications in the working copy or commits that would prevent ff) would be nice. Also the manual sync button should be enabled if these conditions are met as it would effectively work as a shortcut if you don't have syncing enabled.
(In reply to hifi from comment #7)
> That would be much better in my opinion than leaving you "hanging" without
> any idea why the sync "isn't working".
> So offering to fast-forward the current branch if it is by all means
> possible (no unsaved modifications in any editor tab for the files or saved
> modifications in the working copy or commits that would prevent ff) would be
Not sure if we can ensure that for 100%, but in case you have local modifications preventing the checkout the checkout will probably just fail - with the same result.
> Also the manual sync button should be enabled if these conditions are
> met as it would effectively work as a shortcut if you don't have syncing
That's what i offered as a solution for bug 248334, but you were kind of against it :-). That button would offer you the same as during pull (if a merge is needed, then offering merge or rebase)
fixed: core-main #37e39335d381
Integrated into 'main-silver', will be available in build *201411080653* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
User: Ondrej Vrabec <email@example.com>
Log: Issue #248332 - Offer sync of the current with tracked branch after Fetch
Just got around testing the sync suggestion on fetch for current branch, works nice and is a welcome change. Thank you.
I must comment after using this for almost 6 months now that it's a beautiful thing.
I do stuff, co-worker does stuff. He pushes, I fetch, NetBeans asks me if I want to synchronize the checked out tracked branch, I agree, NetBeans tells me it's not a fast-forward, I select Rebase usually, cue magic if no conflicts, I'm now ahead of origin, I push my changes and we're done. I didn't need to go through anything else than two useful dialogs.
Even when there's nothing to merge it's very handy that it will automatically sync the checked out branch so continuing a project is as fast as one click on "Fetch from Upstream" toolbar button and agreeing on the dialog.
In addition getting the rebase/merge stuff flowing with dialogs as suggested in bug 250823 and 250826 will definitely be a big improvement as well. I might not need to hold everyone's hand all the time after that.
This is how you support workflow! It's just brilliant to be working with the nightly version. Now the only thing we're missing is a release. My co-workers are struggling without these and they generally only use the stable releases.