Eclipse EGit Checkout conflict with files: - EGit doesn't want to continue - eclipse

I've started Eclipse EGit. In some scenarios it is really not comprehensive.
I have local file e.g. pom.xml changed. On git server this file was changed.
I do pull, EGIt says:
Checkout conflict with files:
i.e. pulling stops (fetch is done, but not merge), that is OK. However the next is bad experience.
I synchronize workspace, put my changes aside and make it the same as FETCH_HEAD. But EGit doesn't want to continue. I replace the file with HEAD revision. But EGit still doesn't want to continue.
What standard expected user operation should be with EGit after conflict resolution?
UPDATE:
I added to index, then marked as Merged -> pull still can't pass.
When I select Merge I get the dialog
I can't commit the file as it is not in list of changed files.

Situation:
You have local uncommitted changes
You pull from the master repo
You get the error "Checkout conflict with files: xy"
Solution:
Stage and commit (at least) the files xy
Pull again
If automerge is possible, everything is ok.
If not, the pull merges the files and inserts the merge-conflict markers (<<<<<<, >>>>)
Manually edit the conflicting files
Commit and push

This is the way I solved my problem:
Right click the folder that has uncommitted changes on your local
Click Team > Advanced > Assume Unchanged
Pull from master.
UPDATE:
As Hugo Zuleta rightly pointed out, you should be careful while applying this. He says that it might end up saying the branch is up to date, but the changes aren't shown, resulting in desync from the branch.

After closing the Conflict Error Dialog; from the Project Explorer, right click on the head of the project -> Team -> Stashes -> Stash Changes
Enter a name for your stash. E.G. "Conflict"
Try Pulling again. Hopefully there are no errors this time.
From the Git Repository view, expand your repository -> Stashed Commits
Right Click on the stash you created in step 2 -> Apply Stashed Changes
This brings up the merge tool if it can't automatically merge it.
Manually resolve the merge conflicts in the file/s.
Right Click on the file editor -> Team -> Add To Index
If you are not ready to commit the file or just don't want it in the Index, right click on the file editor -> Team -> Remove from Index.
Cleanup: From the Git Repository view, right Click on the stash you created in step 2 -> Delete Stashed Commit
Your local working directory file should be be merged

If error comes for ".settings/language.settings.xml" or any such file you don't need to git.
Team -> Commit -> Staged filelist, check if unwanted file exists, ->
Right click on each-> remove from index.
From UnStaged filelist, check if unwanted file exists, -> Right click on each->
Ignore.
Now if Staged file list empty, and Unstaged file list all files are marked as Ignored. You can pull. Otherwise, follow other answers.

I guess the best way to do this is like this :
Store all your changes in a separate branch.
Then do a hard reset on the local master.
Then merge back your changes from the locally created branch
Then commit and push your changes.
That how I resolve mine, whenever it happens.

After you get from Eclipse the ugly CheckoutConflictException, the Eclipse-Merge Tool button is disabled.
Git need alle your files added to the Index for enable Merging.
So, to merge your Changes and commit them you need to add your files first to the index "Add to Index" and "Commit" them without "Push". Then you should see one pending pull and one pending push request in Eclipse. You see that in one up arrow and one down arrow.
If all conflict Files are in the commit, you can "pull" again. Then you will see something like:
\< < < < < < < HEAD
Server Version
\=======
Local Version
> > > > > > > branch 'master' of ....git
Then you either change it by the Merge-Tool, which is now enable or just do the merge by hand direct in the file. In the last step, you have to add the modified files again to the index and "Commit and Push" them.
Checking done!

The proper solution is the one provided by #Jojo.Lechelt.
However if you don't want to commit for any reason and still want to pull the changes,you may save your changes somewhere else,replace the conflicting file with HEAD revision and then pull.
Later you can paste your changes again and compare it with HEAD and incorporate other people changes into your file.

Right click on the project and select [replace with] -> Head Revision .Now select pull changes in current branch or pull changes from upstream.

In Eclipse :-
Right click -> click on 'add to index'
Add conflict file in staged area
Right Click ->click on commit
Add conflict file in local repository
Pull
You will get all changes (change in remote repository and local repository)
Changes mentioned as Head(<<<<<< HEAD) is your change, Changes mentioned in branch(>>>>>>> branch) is other person change, you can update file accordingly.
Right click ->click on add to index
Right click -> commit and push

I have completely different experience with this problem.
when I pulled (my staging are were clean!), I saw lot of files in staging after pull, which I didn't changed or added, So I cleaned staging area again by replace with head. After trying pull again I faced same problem again, now this time I did following:
stashed changes
Close any file open in another program from your repository
Try pulling
Hope this solve your issue.
Thanks

Related

Eclipse neon "no staged files" error

I am using Eclipse Neon for Github, to be able to push changes.
I already have a Github account and made a specific repository just for trying, but nothing ends up in the repository, though I follow guides and do exactly the same without getting any errors, but ending up with an empty Github repository (except for the Readme file that I created along with the repository at the website).
I've made several Java Projects with a simple main method, and a method for just writing a dummy message, simple, but doesn't exist in repository.
Then I right click the project, select Team -> Share Project and select:
Repository: NewGit - /home/jannik/NewGit.git, working tree: /home/jannik/NewGit and Path within repository: dummy and click my dummy project and press finish.
Now I right click my project again and choose Remote -> Push and choose the default option called Configured remote repository which says origin: https://github.com/< my-github-account>/eclipseTest.git which tells me that it links to my repository named eclipseTest (which I made on website).
I then press Next and press *Add all Branches spec and clicks next, and then Finish. I then get a dialog saying that Master and NewGit branches are up-to-date, though my dummy project is missing.
If I try the Commit option in Eclipse, I get an error saying that there're no staged files
What am I doing wrong?
Before being able to push anywhere, you need to add and commit first.
See "EGit/User Guide/Commit" for adding and committing.
Its Track Changes sections shows how to add files to the index.
Click Team > Add to Index on the project node. (This menu item is named Add on older versions of Egit.)
Then:
Click Team > Commit in the project context menu.
Finally, you can push.
go to >Theam > commit >
you will get the changed list of files and in those you can move changed files to staged changes block and then commit.
See this image you can find the solution:

eclipse egit some files won't commit to github

I have a github repository and it is integrated into eclipse. I sometimes create files in other text editors, then refresh my project and then left click the project to get >Team>Commit. This usually gets every file. Unfortunately, I have several files that failed to commit this way. I don't see them on github and I can see the following when I do Team Synchronizing.
There is nothing I can do to get these files to commit to github. Can anyone see why? These is no error message or warning or anything. When I go to commit these files, they don't appear in the window that shows everything that needs to be commited (ie is new or has changes).
In Eclipse EGit, the preferred way to create commits is by using the Staging View. It shows a clear view of what files are staged and ready to commit and what changed files are not. It supports drag-and-drop to move files from un-staged to staged, as well as commit and commit+push directly in the view.
Open the Staging View and see if those files are in the Unstaged section. If so, drag them to Staged and then commit.

Failed, DIRTY_WORKTREE in eclipse, how to solve it?

I am currently working on a java project and when committing my changes and pulling I get the following error. I don't know how to resolve it:
I tried everything, but can't seem to fix the problem, can someone please help me?
To be clear, I am using eclipse.
Delete the affected files and try to pull again. Thereafter push your changes to the git.
below steps may help
delete non-versioned files
git clean -df
reset your local changes
git fetch
git reset --hard
I got the same error while trying to merge the code. Delete the respective file in either of the branches to merge
Assuming your working in a local branch, that is branched from a remote branch, and the merge conflict is occurring after you 'commit and push' upstream, merge to remote branch.
Try these 3 steps:
Copy off the new changes from the specific file causing the merge issue.
In Eclipse, Explorer pane, rt-click on the specific file causing the merge issue, and select replace with previous revision.
Now perform a 'commit and push'
Perform a merge to remote branch (no conflict should be observed).
In Eclipse, rt-click on the specific file again, and select 'pull' - the file should now be in sync all the way through.
Now add the new changes, save, commit and push, and merge to remote branch (not conflicts should be observed).
In my case, I had uncommitted changes.
I committed my changes and then I was able to merge successfully without dirty_worktree error.
So... another option that worked for me and my DIRTY_WORKTREE... Stash your changes and then Pull.
This solution meant that I did NOT lose some local useful logging changes from simply deleting the offending file.
I had the same error as:
DIRTY_WORKTREE pom.xml
So I deleted the pom.xml from my working directory and did a pull from particular branch.
It worked for me.
I resolved this error by selecting "Assume Unchanged" for the file that I was unable to delete.
STS, In the toolbar. Show View->Git Staging->Unstaged Changes.
OR
Right-click on the file->Team->Advanced->Assume Unchanged
The most simple and easy way is to Rebase
Right click Repo > Rebase
See image
Stash your changes
Done, WOW
From the stashed changes just compare and take necessary code or you can apply stash

EGit: How to restore git to to the clean state

I read few threads on backing out commits. Following are relevant
How to delete commits with egit?
What's the difference between Git Revert, Checkout and Reset?
But how do I revert/reset/restore back to clean original state. I just started working on new project and the original git directory structure got messed up after the first check in (because I incorrectly created git repository as eclipse project); this problem is discussed in "The short story" or "The longer story" of following link
http://wiki.eclipse.org/EGit/User_Guide#Creating_Repositories
Now I wanted to restore the original directory structure of git repo. In History window, I see all the previous commits and I can right click on them and back out to one of previous commits; sadly the history window doesnt show anything to prior first check in (or commit). But I want to back out to the original directory structure that existed prior to first commit (that way I will have clean repo without any code base in it). It doesnt matter if it is restore/reset/revert as long as git repo looks same as it was before first committ. Can I do this in eclipse/egit?
This isn't something that Git would have kept track of.
You might look into the Eclipse local history (which is separate from the history recorded by Git), but that is for a file only. Not a all structure.
It is best to recreate a Git repo, and make as a first commit your clean structure, before adding code base in it.
Go to git perspecive-> Expand the repo. Right click on working tree. Clean. Finish. See the below pasted image link.
clean in git perspective

Can't add new file to repository in EGit

I'm using EGit with Eclipse Juno.
I worked with a local repository and the world was good.
Even adding a GitHub repository seemed to be fine. I added it to my local repository under "Remotes", so I can easily push commits to github.
But after a while, I noticed that no new files are added to the repository, even if I'm commiting changes.
They just are not under version control. They have no symbol, which should mean they are ignored.
This is my .ignore
.gwt
gwt-unitC
ache
Versandanzeige_Web_proto.war
Versandanzeige_Web.war
war/ajax
war/WEB-INF/classes
war/WEB-INF/deploy
www-test
The files are in src, so not even close.
The new files don't appear in the Commit-Dialog, even when checking "show untracked files". They don't appear in the Staging-Window.
RK -> Team -> "Add to index" doesn't help.
The files have the same right and are owned by the same user
They definetly dont show up at github
Any ideas how to fix that? Any additional information needed?
Update:
There are no errors in the error log.
I do have (HEAD) next to my newest branch.
More details:
I got my trunk T, beginning at T0. At T1, there is a branch A, which has changes to T1.
At T2, there is another branch, B. It has no changes to T2.
The strange thing: it is not indicated in History view. The master branch is also missing.
I can still switch to them. When I do git reflog, there are no entries before or including T2, just everything afterwards.
I removed the branches without commits:
The new files are still shown as ignored:
Output from command line:
$ git branch -a:
* master
maven
$ git status
# On branch master nothing to commit (working directory clean)
About the detached HEAD proposel: I didn't do what is described in the article, checking out an old state and work from that. And I can't see any undone commits.
Sorry for my bad english, I didn't use it for a while. Please ask for clarification, if I write something hard to understand.
Update:
I could add a file in another folder (/Versandanzeige_Web/war/WEB-INF/lib/gwt-servlet.jar).
Alright, I found the error.
For some reason I don't really know, there was another .gitignore file ABOVE my Project folder (in repository folder), where my COMPLETE project folder was included. I really don't know how that happened. Of course, this file didn't show up in Eclipse.
I tried to add the files on the command line, but gut the error message "File is in .gitignore file".
After deleting that file, it worked find.
Sorry for the trouble.
Sometimes EGit does not work properly and add to index does not work. In that kind of situations you can go to the root folder of your project (where .git folder is placed) with a file explorer, right click on an empty area inside the folder, select "git bash". This will open the git console for you. Now type "git add path_to_file". This will add the file to the git system for indexing. Now go and refresh your project in eclipse and you will see it is added to the index. This can be used wile resolving conflicts inside eclipse because adding to the index indicates "mark as merged" to the git system by re-adding the merged file.
Also sometimes the "Remove from index" does not work in eclipse, you can do the same thing in that kind of situation: this time write "git remove --cached -f path_to_file". Here do not forget to add "--cached" because otherwise your file will be deleted. -f stands for "force" to force the command. For any folder (directory) to remove from index type "git remove --cached -r -f path_to_folder".