How to resolve a git conflict when pulling (in eclipse) - eclipse

I accidentally made a mess of and then deleted a java project from eclipse (more specifically, I accidentally moved the classes to a different project and then moved them back, and then deleted the project [from the file system] in eclipse), and now whenever I try to do team -> pull (after running ant -f ...), a window pops up saying that there's a checkout conflict with the files that were deleted. How do I get past this conflict and make pulling work again? I could create a new workspace, checkout everything into there again, and copy the code that I'm currently developing into that workspace, but there must be an easier way. Please educate this git n00b.

Open the "Git repositories" view (Ctrl 3 -> git repositories), right-click your project, select "reset".
In the following dialog, enter "HEAD" in the "Reset to (expression)" field and select Hard.
This will completly reset your workspace to pristine state.
Now, reimport your deleted project (File -> import... -> Existing project")
Now everything is back to the state before your "mess" and you can pull again.

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:

Cannot move project as it overlaps... Git/Eclipse

I am trying to move a project into my git repo, using Team -> Share Project -> Git, when I select the repo the error "Cannot move project x to target location...as this location overlaps with location..."
My workspace and repo are different folders (this seems to fix it for most people).
Which version of eclipse and egit plugin are you using?
For me on Kepler Service Release 2 and Egit 3.2.0 it works if I choose:
Team->Share Project->Git
and then tickbox Use or create repository in parent folder of project BUT then select the project folder . instead of the parent ..
In my case, there was a .project file inside the git repo. I just deleted it from the terminal. Then everything works perfectly. You can't access it with the GUI which is another reason why terminal is awesome!
Tried many options but they didn't work. I've posted an answer in another similar question which is a manual way to do it which will work with any Eclipse version, here is the link: https://stackoverflow.com/a/41799215/578046
I got this error when attempting to bring in a new subproject into an existing parent project in a "split" workspace i.e. the default configuration using separate workspace and git folders.
The final workaround was different from others listed:
Delete the project from within Eclipse (choose default option: DO NOT delete on filesystem)
Use the system shell move the new subproject from the Workspace location into its proper place under the parent project in the git folder structure
In Eclipse, go to the the Git Repositories view, right-click the new project folder under Working Tree, and choose "Import Projects..." to reimport the project
Re-add the project to any Working Sets it needs to be part of
I encountered the same problem, and used the following steps to solve the problem:
1、Team --> Share Project...
2、Check Use or create repository in parent folder of project,and then Check Your project...
3、Click Create Repository
4、Click Finish
I had the same problem and realized that when i cloned the git repository i selected the "import all existing Eclipse projects after clone finishes" checkbox. So i removed my repository and cloned it again without the checkbox selected. Then i had no problem sharing a new Java project into my repository (because no .project file was created on the git folder)
I had the same problem, here's how I solved it:
Open The Git Repositories View:
Window -> Show View -> Other -> Git -> Git Repositories -> Open
Then Right Click YourRepositoryName in the Git Repositories View and Click Clean...
A Popup Window will open, Tick the .project file and Click Finish
Now when you try to use Team -> Share Project -> Git it should work.
If Clean... doesn't delete the .project file, you can also manually do it by opening the repository file system in the Git Repositories View and look for the .project file then Right Click the file and Click Delete
I just went to git folder using terminal and entered the command rm .project. The problem went away.
I had a similar error once, which was caused by the name of my folder containing spaces, e.g. "Joe Doe".
Moving the project to a place where it doesn't have any space in file path solved my problem.

Reconnecting a project to SVN in Eclipse

I have a project that has been versioned by SVN for months, but now all of a sudden it seems that Eclipse does not recognize the project as being under version control. In the team menu, I only have Apply Patch... and Share Project...
I tried Share Project as suggested elsewhere, but Eclipse doesn't recognize the project as being under version control.
All the svn dirs exist.
Interestingly, I tried sharing the project to a different repository and I got an error saying that the project was already a working copy for another URL.
Any ideas?
There are a few things that you can try.
If the project is in synch with SVN, probably the easiest way is to delete it and check it out anew.
Otherwise, you can try to delete the project from your workspace (not from disk!) and to re-import it into the workspace.
If that does not work, you can try to use the SVN command line tools, e.g. svn commit, to synchronize your local project with the SVN repository (and check it out anew using Eclipse).
In case the SVN command line tools do not work, there might to be an actual problem with the SVN files. In this case, you could back up your project (with unsynched changes), check out the project from SVN, and use an offline-diff-tool such as diff or meld to carry the changes over to the newly checked-out project.
Try following: Rigth click -> Team->'share projectS' (plural, in singular does not work) in your disconnected project
I cannot reproduce it now in my PC but there appears a option to reconnect to svn -or to connect using svn information that exists in project-. (Just do as you were going to put a new project in svn, it will see the svn info and will asks you to use it)
I hate that problems....
Team > Share project works fine. The disadvantage is SVN supports to share projects one by one rather than many projects at a time.
4 years too late, but for anyone who faces this problem :
If while disconnecting from SVN, the meta-data was erased :
Right click on the project ->
Team -> Share Project -> SVN ->
Use existing repository location -> Next ->
Browse to your project's trunk folder -> OK -> Next ->
Here you will get a commit comment box. Just press Finish ->
A warning sign is displayed in a popup window saying "The project xxx already exists in the repository and has some content. Do you wish to proceed?" ->
Click yes ->
A window will popup showing the progress of prepare commit ->
After completion you will get the actual commit window showing all the resources as modified ->
Click CANCEL here ->
It will connect your local project to SVN and also will not commit anything.
I had better luck with the singular version of 'share project'. Had to manually add 'trunk' to the suggested repository path.

Eclipse Egit Not Detecting Changed Files

I have been using Egit and Eclipse together for well over a year. I recently upgraded my computer and had to reinstall everything. Previously whenever I would make a change to a file it would immediately get picked up by Egit and show with the red highlight and star next to the file name in the project explorer.
I have everything back up and running exactly as it was, however whenever I make a change the change is not picked up by Egit. I have to perform a 'git status' in order for the files to show as ready to be staged in the file explorer. Am I doing something wrong to have Egit automatically detect changed files and has anyone else had this problem?
which version of EGit are you using
do you get the egit team menu if you right-click any resource in your git tracked project ?
if not then you need to do "Team > Share > Git", then check "Use or create repository in
parent folder of project". If you are using a very recent nightly build version this
will be checked automatically.
when you modify a file tracked by (e)git a text decorator ">" should
appear in front of the modified file
as soon as you stage the modified file (Team > Add) the decorator should show the star
also the staging view should always show the git status for all modified files
You need to "Add to index" all files again probably
Track Changes Click Team > Add on the project node. (This menu item
may read Add to Index on recent versions of Egit)
(From the EGit docs:)
What I've found is that you need to make sure that your git repositories are showing up in the Eclipse Git Repositories view.
In the repositories view, you click on the [very] little Git icon with a green + (plus) sign to Add and Existing Local Git Repository.
Browse to the directory that already has a .git subdir and click Finish. You should then see you local repo show up in that list.
Then you can right click on the repo while still in the repositories view and add pull down to Import Projects.
"Import existing projects" is selected. Click Next.
Your project should be checked off. Add it to a working set if necessary. Click Next (maybe Finish).
I had a similar issue where all my changes just disappeared. Somehow, Eclipse had unselected my Git repository. Once I selected it again, they all came back.
If you have already added your files to Stage then change the branch it will ask you to commit/stash/reset
I faced the same problem. From your git repository view: Right-click -> Show in git staging
For me I have clicked Team --> Advanced --> No Assume Unchanged, fixed the issue
I faced the same problem using eclipse version 2021.12. Whenever I made changes on file, the eclipse didn't detect it.
I solve it by using Intelij IDE.
i just faced this problem by now, and i resolved by clicking in button Refresh in Git Staging:

Eclipse + EGit: clone project into workspace

I'm a little confused about how EGit workes.
I have an existing git repository on Github and want to clone it into my workspace.
My goal is to have the local repository directly stored inside my workspace-folder but I don't get it working with EGit.
When I want to clone the github repo with EGit, I have to choose a directory as destination. The suggested directory is in my homedir (not in my workspace). When I choose this directory I can see the project in Eclipse but it is not stored in my workspace-folder. Instead it is stored in my home dir.
When I choose a directory directly inside my workspace, later when it comes to import the project it says that there is already a directory with this name.
I don't know how to solve this. I thought this would be a common scenario. In the past I have used hgEclipse (Mercurial) and it was working exactly the way I thought it should be so I'm confused EGit doesn't. Maybe I misunderstood something.
Probably this is important to know: In the github repository there are no .project or .settings files from eclipse. I have them on my .gitignore and so in the import-dialog I have to choose "Import as General Project" and not "Import Existing Projects". But I think this shouldn't matter?
I hope someone can help me or explain me why the EGit plugin doesn't clone the repository directly into the workspace by default.
My Eclipseversion is 3.6, I have installed EGit over the markedplace.
As mentioned in this EGit tutorial, the destination directory you mention when importing (cloning) a Git repo is any directory you want, in which the .git will be created:
You don't have to select the workspace itself (at least, you should select the workspace/myproject subdirectory, in order to not make the all Eclipse workspace a Git repo.
And you can select any other directory outside the workspace: the Eclipse workspace should only contain meta-data about Eclipse projects and settings.
When declaring a new project, you will be able to select the project directory, making that directory the parent for .classpath and .project.
Your workspace will list that new project, even though it lives outside the workspace.
To import a project from GitHub you should use the Import Git Repository as New Project dialogue (right click -> Import -> Git -> Git Repository as New Project). This way you can select the destination of the clone repository, including the Workspace.
If you want to edit the sources in the IDE and also want the changes to be reflected in the Git repository, delete the original source file in the project and link the source file in the git repo to the project. That way, you can directly make changes to the git repo and you can commit them when needed. Be careful not to delete the files when deleting the project in the IDE though.
Steps to have git project in workspace (with egit):
On GIT perspective choose "Clone a Git Repository and add it to this view"
As a destination choose folder inside a workspace (for example ".../workspace/myproject")
Wait until cloned
File -> New -> Project
General -> project
As a project name type name of a folder in workspace where project has been cloned (for example "myproject")
Nope. There's no way to get this to work. You can't use egit to checkout a git project into the workspace and if you check it out elsewhere and try to copy it into the workspace, you will lose your connection to the remote repository. If you want VCS that works, use svn or mercurial.
In the "Configure Local Storage Location" dialog,
choose .../workspace/projectname.
Then in the next dialog,
we get the wizard selection menu. Normally you should select "Import existing project".
(But see below).
Finally, there is the "Import Projects" dialog.
For various unexplained reasons, sometimes this dialog is empty and won't
let you finish. In that case, you need to cancel, and then outside of Eclipse completely delete the working directory that was cloned into, and then start again.
But if there is the project there, press finish. If it complains about the project already existing, go back to the wizard menu and change it to use a wizard. Select a Java wizard and then finish. Often this will work, but only if you first got the "Import Projects" menu to recognize the project in the first place.
It may take several attempts to get this to work! But once it is set up, it works fine.
So, in summary: is is possible to get EGit to use the default project location for the git clone, but in my experience it may inexplicably require several attempts.