Eclipse EGIT - all committed, pulled, merged, marked as merged, still on push I get "rejected - non-fast forward", what am I missing? - eclipse

I'm starting to experiment with Git, and I'm sure I'm missing something, as I can't do a simple merge and push
Here is what I do (I probably got it in the wrong order, or wrong in any order, please correct if it is)
pull
Syncronize Workspace
on conflicts - did a manual merge,
then "Mark as Merged" (is it necessary?)
on the rest - allowed the automatic merge
commit my changes
pressed push (origin-master)
I get the famous "rejected - non-fast forward"
did a "fetch" to check - nothing to update
did another commit - nothing to commit
What am I missing?
Not sure if it's relevant but I'm using Windows 7, EGit (1.3.0.201202151440-1) in Eclipse Indigo (SR2, build 20120216-1857) and pushing to GitHub

I think I found it, instead of "Mark as Merged", I need to do "Add"
Manual conflict resolution
To resolve a conflict you have to do the following steps:
Navigate to the conflicting resource Edit the content of the conflicting resource Tell EGit that the conflict is resolved with Team -> Add
Commit the conflict resolution with Team > Commit
from http://wiki.eclipse.org/EGit/User_Guide#Manual_conflict_resolution
Edit: apparently, I should have learned git command line before playing with EGit, same concept there

Related

How can I get rid of Eclipse Git "conflict" icons after all merges are resolved?

I get the Git conflict icon in Eclipse on lots of files, even though it seems that I resolved any possible conflicts.
In Eclipse 4.5.2, in the Project view, I select a project root and do right-click -> Compare to branch origin/master. Next, we see the Team Synchronization view. Many files show a red conflict icon., but they should not.
The Git staging view, which is supposed to show conflicts, is empty. I already tried Merge; Committing the merge (nothing remains to be committed). I tried Add to Index from the Git Staging view; and even Overwrite from the Team Synchronization view. Comparing the local and origin files shows that they are identical.
Git setting autocrlf is true, so that is not the issue.
This occurs repeatedly.
Why do I see this conflict icon? How can I get rid of it?
Did you do a pull? Or where you just comparing in Team Synchronization? In my experience the Team Synchronization perspective confuses the most people.
In general it should be used "read-only". Don't try to resolve any conflicts here. Per default you are comparing your working copy against the remote repository. Which means you actually have no conflict in your working copy. When you "fix" them here you are just making a local modification. You can commit that but it doesn't resolve any conflict. It makes the actual conflict even harder to resolve.
So don't do anything in the Team Synchronization perspective. Just do a pull to have those conflicts in your working copy and then resolve them. A merge conflict is marked as merged by moving them to the Staged Changes.
If something breaks and you want a new try do a reset --hard on the last commit in your local repository.
After editing the conflict resource properly. Right click on the conflict resource and click on *Mark as Merged".
See Resolving_a_merge_conflict. Also check this screen cast.

Which sequence should be follow to synchronize code (commit and update) using Egit?

I am quite new with Egit (An Eclipse plugin for git).
I am getting weird errors (like dirty tree, conflict exception) while synchronizing code when there is conflict between local file and remote file.
So which sequence I should follow for use git in better way?
Right now I am performing following steps:
Fetching
Merging (in this step I am getting errors using Team synchronization.)
Add to Git index (in case there is conflict)
Committing
Please help me better way if any.
That seems correct, as described in the "Resolving a merge conflict" of the EGit User Guide.
This EGit tutorial adds the following tips:
Use the Git staging view to find the conflicting files, in large projects that is usually faster than navigating the Package Explorer view.
The rest follows what you are doing:
Once you have manually merged the changes, select Team → Add from the context menu of the resource to mark the conflicts as resolved and commit the merge resolution via Team → Commit.

Failed merge in EGit

I did a fetch from my remote origin to get the latest master branch that my friend had pushed to. I wanted to merge with my own master after the fetch, but whenever I do a merge with origin/master it just says "Failed". I've made hard resets before trying again with same result.
Since "Failed" is pretty vague I'm asking here what to do.
I have looked on the Egit wiki, but they don't mention failure as a possible result. This tutorial says that "A Failed result may occur when there are already conflicting changes in the working directory.", that's all I've found by googling.
Egit 2.2.0
Eclipse Build id: 20130225-0426
So the problem was Egit failed a merge without saying why.
After playing around in the staging view and, by a leap of faith from someone not entirely comfortable with Git, added all the unstaged files to the index (which is strange since I did a hard reset, why should there be differences?) I committed it. After I had done the commit, another file (a .jar) popped up in the unstaged list (why wasn't it there until I made my commit? Seriously). I added it to the index and committed. Finally there were no unstaged files.
I tried merging, and it worked. At last I got the "conflicted" result instead of "failed". Added everything to index and committed. Finally I seemed to have merged successfully, and I could push.
Honestly can't tell if I made mistakes or if Egit doesn't work properly.
In the Git repositories view.
1. right click the local -> master branch
2. select push branch -> next
3. it pop up a 'select push destination' window, check the 'force update' in it.

eGit checkout conflict - can't reset

I have 2 branches: master & develop. I have been developing in "develop" and committed everything I need. What was left (application generated file: .out) I didn't care for! So when I went to switch branch, I got prompted following:
I clicked "Reset" however instead of switching to the branch I got prompted the same "Checkout Conflicts" windows with exactly the same choices. I clicked "Reset" again, however above process just repeated. I clicked a while -- no help the same happens again and again. More over I encountered the same scenario on different eclipses (Juno, Kepler) and different OS (Mac & Windows).
Am I doing something wrong? I don't want to commit or stash the file, I just want it to be reset. Is it a bug? Or there is a solution?
Thank you.
Add *.out to your .gitignore to get rid of those files once and forever.
In my version of egit, when i select reset, the reset window opens. Seems like a bug in your version. Try updating egit (not only eclipse).
If it still doesn't work, you can also use Team -> Reset... to perform a reset. After that you should be able to change the branches.
Actually, there are a few more ways to kill a file:
just delete the file
commit it and then reset the branch to the commit before that (effectively getting rid of that commit)
commit it and then perform an git rebase -interactive and delete the corresponding line
Feel free to edit this post and add more ways of violently killing a file from git!

Why is the merge tool disabled in Eclipse for a EGit-managed project?

As per the EGit User Guide, to use the merge tool, one should right-click on the resource with a merge conflict and then select Team > Merge Tool. However, when I do this, the Merge Tool option is greyed out. EGit is properly detecting the conflict and showing me both the icon and text label decorations for the file in conflict.
Any ideas?
It was disabled for me because I had some changes on my stash list.
$ git stash clear
fixed the problem for me.
It can depend on the version of EGit you are using, and on the operation that lead to the conflict.
See for instance bug 339092 which mention merge tool being not enabled in the case of a conflict after cherry-picking: only the just released EGit 0.12 would support that.
The only time (other than a bug) that the Merge Tool would be disabled is that when you are in any status other than the Conflicts one; i.e. you will only see that option enabled when the status is Conflicts. The status is shown next to the project name in most views, such as Project Explorer and Synchronize.
Make sure you have merged with desired branch, then if your merge results in conflicts, your project will enter Conflicts mode, and the Merge Tool will be enabled.
It seems to be a bug in EGit as VonC mentioned, but the fix is easy. I did it using reset branch option on the same menu that Cherry Pick option existed.
Note: git stash clear didn't help.
This happens if you tried to push changes to a remote and there were merges required from the remote. It fails with 'not FF' but also simultaneously detects the conflict. Don't ask me why it doesn't mark the whole project as conflicted at this point.
Open the Synchronize tab, right-click the project and select 'merge'. This immediately fails because of the conflicting file, and it switches on the conflict icon label for the project and enables the 'merge tool' option.
This is for EGit 4.0.3 in Eclipse Mars.
This also happens if you're in detached head state (in my case, I had checked out a remote branch and then forgotten).
Also, even after you've corrected the problem, you may have to select a different project and then reselect the one you actually want (just selecting in the package explorer view) in order for the menu to update.