Howto recover from bad git merge in Eclipse - eclipse

Eclipse Jave EE IDE for Web Developers
Luna Service Release 2 (4.4.2)
Eclipse EGit 3.4.2.201412180340-r
So I am merging between two Git branches in Eclipse, something that I have done dozens of times without incident.
This time, for some reason, conflicts were detected. I'm not sure why. But nothing I do in Eclipse lets me get rid of them. I've used the "merge tool". It let me manually move over all the changes to just the way I wanted it to be. Saved the file, conflict did not go away. Won't let me add to index. Won't let me commit. Tried the Team Synchronizing perspective, with its "Mark as Merged" function. This had no effect, although I remember it fondly from the "bad old svn days".
Many outdated web pages exist which tell me about >>>>> and <<<<< marks. None of these are to be found in my file.
How do I get to the bottom of this? Short of deleting the project from Eclipse and recloning it from the Atlassian stash it remotes to, how can I get out of this catch-22?
Update: answered my own question. see below.
Yup, it's definitely a bug in the eclipse git tooling.
After all this, I came upon Eclipse EGIT - all committed, pulled, merged, marked as merged, still on push I get "rejected - non-fast forward", what am I missing? and tried the solution referenced there. This was partially effective. I went straight to editing the conflicted file, and found the >>>>> and <<<<< marks. I was able to edit and save the file, and when I added it to the index, the marks went away.
But there was still a problem. My file contained both changes that were marked as conflicting and changes not marked as conflicting. When I edited the file directly ONLY the conflicted changes were in the file. The non-problematic changes did not make it into the file. To get those I had to do a manual compare of workspace with branch and move those over.
Sheesh.
So here is what we have.
The "merge tool" is worse than useless for conflict resolution. It strips out the >>>>> marks which makes manual editing difficult. Also, "Team-->Add to Index" doesn't work after you use the merge tool. Don't use it! At least until a fix is released.
Manual editing would work if the non-conflicting changes were added to the file.
Beyond this, there shouldn't have been a conflict anyway. The "conflict" amounted to a blank line vs. a section of new code. If the differencer can't figure that out, that's a problem too.

Oops, from the history view, there is Reset-->Hard Reset. That gets me back to pre-merge. I feel dumb for having posted this question but will leave it up in case someone else hits this.

Related

Eclipse + Git Team Synchronizing is useless

We recently have moved from SVN to GIT, and until recently, the problems with the move were if not minimal, at least manageable.
Until a few weeks ago, we just had a single active 'master' branch, which was the old SVN trunk. But then, we added a branch to do a major upgrade while keeping the master available for bugfixes that could then be easily deployed.
The problem is that as soon as the different project team members started to check stuff in, the Eclipse (Mars 2 with EGit) Team Synchronization perspective started showing stuff as needing to check in that really didnt.
The first time I synchronized, a load of incoming changes came in (the blue arrow) which was unusual as I hadn't seen any since moving to GIT, - we just had to do a PULL instead - so foolishly I accepted them in. That ended up merging the changes we had put in the trunk with the branch, which we DIDN'T want to do.
Worse, even after pulling in those changes, they still appeared but now as conflicts, even though I accepted them and the files were identical. Nothing I can do (Mark as Merged, Overwrite, Commit...) gets rid of them.
Anyway, the most unhelpful problem is that now the Team Synchronization brings in hundreds (currently 825!) supposed changed files when I do a synchronize now. Many of these files are obscure ones that havent changed in years, and are clearly unchanged yet they show up. Trying to sift through the file list to find what I have actually changed is too much effort, especially as Eclipse helpfully refreshes the list with all the items I removed from the view each time I make any change!
So basically now I am resorting to GitKraken, which has substandard diff tools but at least shows an accurate view of what needs checking in. Why they decided on the Duplo-sized fonts that take up so much window space in the staging area I have no idea. And it's SLOW.
I now have a healthy dislike for GIT because its such a faff compared to SVN, although I acknowledge a lot of this is down to the GIT implementation in eclipse.
So, does anyone have any tips about how to get Eclipse to recognize that most of these files shouldn't actually be displayed? Am I missing some configuration somewhere? When I right click on the project in eclipse and do Team > Switch To, it correctly shows the branch Im working on, so why is it so inaccurate? Im using Eclipse Mars2 4.5.2 with JGit 4.6.1
Any tips appreciated.
For anyone else having similar problems with this, I sort of have an answer.
My answer is, that Im not sure what got it working, but my team synchronizing perspective now shows 99% the correct view. I clicked on various things with increasing desperation to get this to work and then some combination of the below in the Team Synchronizing perspective had the right effect:
In the Synchronize tab, select the down arrow next to the view type and select either Java Workspace (for the master) or Git Commits (for the branch)
Click the down arrow next to the Synchronize icon at the far left, select Synchronize and then Git, then select the correct destination (eg ref/heads/master) and then clic on 'Include local uncommitted changes in comparison'
Hopefully thats of help to someone.

Eclipse Git Repository Branch Hash not updating

I been trying to follow this tutorial on using Eclipse and GITHUB when multiple people are writing within the same project using branches. I believe I understand everything and how its working.. HOWEVER.. my hash isn't updating like the video is showing on local branches.
https://www.youtube.com/watch?v=KfeqnernMmE
If you look at minute 3:50 - 3:60 you will see him do a COMMIT and it will then update on the local branch and generates a new HASH etc...(text in grey next to ChangeDefaults in the video) My Eclipse won't freaking do this. I make a change exactly like he does, I do a commit, but my Hash's and comment text (all the text in GREY) don't update or change at all. They same the exact same as it was before and I'm not seeing any onscreen errors or anything.
What am I missing?
Apparently there were 2 things I was doing wrong.
1) I wasn't using the correct Repository when I was modifying things. I had the wrong "Project" open.
2) I was missing an update and had to update my GIT inside my eclipse.

Unstaged changes immediately after cloning in Eclipse

I'm using Atlassian Stash, and the Git plugin for Eclipse Kepler, and I'm trying to clone a repository. As soon as I complete it, I immediately end up with N unstaged changes, where N vary everytime I try it. When I try and compare the two files that are apparently different, there isn't a single change. I'm guessing there may be some differences between the metadata of the files, but since I can't find what exactly has changed I don't want to commit/push the files either. Like I said, the number of files that have changed are completely random, and the kind of files that have been changed are also pretty random. (.project, .java, .groovy, +more).
I have had a look at this question, this question, and this question but none of them solved my question.
Any ideas as to why this happens?
Like already mentioned in the comments,this is a line-ending problem.
I also had this issue one day.
The git plugin(egit) you are using does have a issue with .gitattributes where you can configure how line endings should handled.
- If you are using the plugin and still want to use it, you need to have to fix the line endings first and than configure your line endings in your IDE to use Unix-Line-Endings, as well as on the other(usually Windows) machine. This will solve the line ending problem for new files.
I am totally against the fact that git should handle your line-endings, you as a developer are responsible for managing this. So let your IDE handle this issue and configure it as already mentioned.

EGit Conflict Resolution GUI?

I think I am just merely (coming from an SVN background) confused with how Git conflicts are handled by EGit within Eclipse.
I understand that it shows textually in the normal standard method by which to show conflicts as stated here: http://www.kernel.org/pub/software/scm/git/docs/git-merge.html#_how_conflicts_are_presented however it isn't very clean and with thousands of lines of code it becomes unmanageable to avoid accidently deleting lines that are not meant to be deleted.
Is there any GUI within EGit that can show me each conflict with an step over ability?
I have searched around and I heard about the merge tool however when I follow the instructions by right clicking on the top level node of the tree (i.e. right click models folder that has the <> type icon denoting a conflict, which has a conflicted file of User.php within it) the merge tool is greyed out.
Am I using the merge tool wrong?
Edit
I found out that a bug can cause EGit merge tool to not show: Why is the merge tool disabled in Eclipse for a EGit-managed project? however I am using EGit 1.3.0 so I should be way past this bug.
I have given this question two days both here and on the EGit forums: http://www.eclipse.org/forums/index.php/t/371459/ unfortunately (even after everyone viewed it) no one had a real answer so I decided to solve my conflicts manually and just merge that way.
This way was, in reality, quicker and easier than trying to solve why the merge tools were not working for me, ironically.

Undo mark as merged

I am using Eclipse Indigo and subeclipse as the svn plugin for eclipse. Now here is the situation. I was synchronizing my project with the remote repository. There were conflicts present and I mistakenly clicked on "mark as merged" for one of the files without merging it. I tried restarting eclipse and some other stupid hacks. But nothing works out. So is there a way to undo "mark as merged" action?
Mark as Merged means that the local version of the file contains the content you want, after having compared the files and manually resolving issues. Subclipse still has to update the local file so that SVN's metadata is happy, so it saves the current content of the file, runs svn update, and then replaces the file.
So you can now run Team > Revert if you want the file to match what was in the repository, or Compare with > Base Revision if you just want to examine the differences again and possibly make more changes.
Neither of Marks suggestions worked for me. The class did revert back to the original (pre-merged) state, but trying to Merge again just gave me a 'no differences detected' message.
What did end up working for me was to Compare With > Local History. I was able to pick a version that was right before I hit Mark As Merged, and that got me back to the Compare Editor view that I had during the original Merge (which showed all the conflicts). I was then able to change the code correctly, and Mark As Merged again.
Delete the local project and re-import it, and this has the effect of undoing an accidental 'Mark as Merged' action. Just make sure that the deletion won't result in loss of uncommitted work.