Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit » Help: Unable to merge between two users
Help: Unable to merge between two users [message #989635] Fri, 07 December 2012 01:27 Go to next message
Peter Carlson is currently offline Peter Carlson
Messages: 5
Registered: December 2012
Junior Member
Myself and another developer have banged our heads against this for the past week and we must be missing something fundamentally obvious. This simple task takes seconds to perform in most VCS. This probably belongs in a pure git discussion, but we are trying to accomplish this using EGit.

in basic:
Master Repository out in the cloud "common.git"

User1: git clone ssh://foo.bar/common.git
User 2: git clone ssh://foo.bar/common.git
User1: edit file 1, git commit -a, git push (no problems, master repo and user1 repo are the same)
User2: edit file 2, git commit -a, git push (dreaded fast-forward error)

Now here is where it got interesting. I(User 2) did a team synchronize and saw <-File 1 and ->File 2. Indicating that the master's file 1 was newer than mine and my file 2 was newer than the master's. So I tried (merge and overwrite) by right clicking on that file. Now a team synchronize showed that I had to upload 2 files, both file 1 and file 2. This made absolutely no sense to me. I tried a pull somewhere along the line and that didn't work either, but by this point I haven't a clue the error.

So my question: with either git cli or EGit(Preferred), what is the proper way to resolve (or avoid) this situation. It is a common workflow scenario, two programmers working on different files. I can't believe with so many people singing the praises of git that it is this difficult to perform such a simple task. Surely I am missing something?

Peter
ps. neither the EGit wiki, nor the git book at git-scm.com show this common scenario.
Re: Help: Unable to merge between two users [message #989771 is a reply to message #989635] Fri, 07 December 2012 11:32 Go to previous messageGo to next message
Peter Carlson is currently offline Peter Carlson
Messages: 5
Registered: December 2012
Junior Member
ok, I will add some clarification on what I have tried in EGit
user1: file import new project from git master repo
user2: same thing

user1: changes file1, commit, push...all is good
user2: changes file2, commit, push - fails non-fsat-forward as expected
user2: team synchronize sees file1 as needing pulled, file2 as needing pushed
user2: right click on file1 and click on overwrite - file1 gets overwritten (and now needs committing...I'd like to come back to this in a future post)
user2: commits file1
user2: push - fail - non-fast-forward

user2: takes sledghammer to computer and feels much better, but gets fired for destroying company property, ends up homeless and at the corner of 1st and 2nd streets dies sad, lonely and gitless

git status:
peter@OFFICE:~/workspace/common$ git status
# On branch master
# Your branch and 'origin/master' have diverged,
# and have 2 and 1 different commit each, respectively.
#
nothing to commit (working directory clean)

peter@OFFICE:~/workspace/common$ git log --pretty=format:"%h %s" --graph
* 0f56d64 forced commit after "overwrite" of strutil.h
* 09023c9 peter 0803
* 55a2508 test
*   fb23440 Merge branch 'master' of ssh://foo...bar.../var/git/common
|\  



Here are some diff details (with extra comments from me)
peter@OFFICE:~/workspace/common$ git log -p

commit 0f56d6433cfbd6ad00c3f677d8314e70a92e29e1
Author: Peter Carlson <peter@howudodat.com>
Date:   Fri Dec 7 08:13:28 2012 -0800

    forced commit after "overwrite" of strutil.h

diff --git a/utils/strutil.h b/utils/strutil.h
index ab02f4a..0154dde 100755
--- a/utils/strutil.h
+++ b/utils/strutil.h
@@ -1,4 +1,4 @@
-// i want to scream
+// peter 2 making a change at 0801^M

commit 09023c98c7c593ed8ecc460c70dbc66d853e44c3
Author: Peter Carlson <peter@howudodat.com>
Date:   Fri Dec 7 08:04:33 2012 -0800

    peter 0803

diff --git a/utils/mathxtras.h b/utils/mathxtras.h
index 190e339..9f2235c 100644
--- a/utils/mathxtras.h
+++ b/utils/mathxtras.h
@@ -1,8 +1,7 @@
-// life just keep getting harder
-// peter changed this line hoping that life will get better
+// peter at 0803

Re: Help: Unable to merge between two users [message #989995 is a reply to message #989771] Mon, 10 December 2012 06:34 Go to previous messageGo to next message
Christoph Keimel is currently offline Christoph Keimel
Messages: 335
Registered: December 2010
Location: Germany
Senior Member
Peter Carlson wrote on Fri, 07 December 2012 17:32

user1: file import new project from git master repo
user2: same thing
user1: changes file1, commit, push...all is good
user2: changes file2, commit, push - fails non-fsat-forward as expected


Hi Peter

we have a similar workflow, but we use EGit a little differently.
1) I never use the Team Sync View, so I don't know what that does
2) After your step of user2 above (after the non-ff-error), all user2 needs to do is:
git fetch
git rebase (or git merge if you prefer)

3) After this user2 can push his commits.

Hope this helps.
Christoph
Re: Help: Unable to merge between two users [message #990030 is a reply to message #989995] Mon, 10 December 2012 10:11 Go to previous message
R Shapiro is currently offline R Shapiro
Messages: 386
Registered: June 2011
Senior Member
The non-fast-forward situation is completely normal in Git (and other distributed version control systems). It's telling you that you can't 'push' because the remote repository has commits that you don't have locally. All you have to do is get those commits into your local branch, which is most straight forwardly done via 'pull'. Most of the time that's it: 'pull', then re-do the 'push'

Since 'pull' will do a 'merge' or 'rebase', you will sometimes run into conflicts at this point. Again, this is perfectly normal. In this case you need to resolve the conflicts before you re-do the 'push'. Basic conflict resolution is mostly just like SVN or any other version control system: edit the conflicting files to have the changes you want. Git has one final extra step: 'commit' those changes. At this point you can re-do the 'push.

The details of conflict resolution in EGit depends on whether you configured your local branch to use 'rebase' or 'merge'. If you're using rebase, EGit should automatically put you in interactive rebase mode [but see below ***]. If you're using merge you might need to invoke 'Team -> Merge Tool' manually,or EGit might do this automatically (I can't remember which, as I always use 'rebase').

Note that the there's no use of the "Synchronization" perspective here. I almost never use this perspective in EGit, except when I want to compare the active branch to some other local branch. In normal development, the 'add' and 'commit' menu/toolbar items are fine for simple changes, and the "Git Staging" view is very nice for more complex changes, for example staging some but not all changes in a given file, and also for reviewing all the local changes before staging or committing them.

By the way if you haven't yet enabled the EGit toolbar, you really should do so. In your main development perspective (Java or whatever), do 'Window -> Customize Perspective...', then select the "Command Groups Availability' tab, then check the boxes for "Git" and "Git Navigation". The former adds toolbar items for all the basic Git operations, the latter adds one to open Git commits in EGit commit viewer (another very handy tool).


[***] Some versions of EGit have buggy behavior when a 'pull' triggers a rebase conflict. I reported this bug some time ago. The workaround is to abort the rebase and then re-invoke it manually, using the 'rebase' menu/toolbar item.


Previous Topic:Cannot Install on CFBuilder
Next Topic:JGIT Get Path
Goto Forum:
  


Current Time: Wed Jul 30 07:26:39 EDT 2014

Powered by FUDForum. Page generated in 0.01769 seconds