Problems with SVN with a project in Eclipse - java

I was working with a project that I was uploading the source to a SVN repo.
For a few weeks I dind`t uploaded any code.
My computer has broken.
I could access to the HD and recover my eclipse project.
Now if I import my project into Eclipse and I want to synchronize with my repo, all my files appear to be in conflicts.
Is there any way that I could "clean" my recovered project so I can stop having conflicts and in this way start to sync my project again with my repo?
When I open a file to see the changes, in those files, where I know that there is no change between my local file and the repo file, my local file version is lower than the repo file, example (local file version: 244 and repo version: 351). But there is no change between one and another file.
How can I get my project working again with my repo?

First do a team -> cleanup on your project. This sometimes resolves some SVN-specific tree issues.
Then go to the team synchronization perspective and do an update of the complete project.
Select the conflicts tab and resolve each conflicted file, there are two options: 'override and update' (dismiss your local changes and continue with the repository version) or
'mark as merged' (indicate that your local file is correct, and the repository version should be overwritten)
Before selecting 'mark as merged' you can use the diff tool to view each discrepancy in turn and edit your local file if necessary. Note that the diff tool has a setting 'ignore whitespace' which might help reduce the clutter.
After you are done, before committing anything re-build the project from scratch and run all your tests.
If you still get stuck there is a more drastic solution: make a fresh checkout of the project in another directory and then copy your local changes into it by hand. Make sure you don't copy any .svn directories!

Related

Accidentally made my Netbeans Project folder a github repository

I've just finished a java course and a project in which we made a small java application. In the project we used github, but since we're all pretty much beginners to java and github this was a rather confusing process.
Therefore I might have made my NetBeansProjects folder, which is NetBeans' default folder for new projects, a repository to our project on github.
At least what happens is that every time I create a new project in NetBeans, it's automatically connected to our project on github.
I'd really like that my NetBeansProjects folder isn't connected to any remote github projects.
I have tried the git remote remove origin which resets the config by the looks of it but it doesn't solve the problem and any projects I create in NetBeans will still connect to our project on github.
Any suggestions to what might help?
If you don't need to keep track of anything in the Netbeans folder anymore, then you can just erase the .git folder which keeps all the git related data (you will lose everything that hasn't been pushed to github repo as well). The .git directory is hidden, procedure to make it visible (/display & erase it) depends on the OS you are using.
If you want to keep using git, you can add the folders you don't want to have in github repo into .gitignore file.

Can't find project in run configuration in Eclipse after importing git repo

I have a remote repo that I've cloned using egit, and imported it into my workspace. I want to run it, but when I go to the run configuration screen I don't see my project or my classes.
I've tried messing with the classpath, and deleted the workspace metadata and reimported. No luck.
Does my build configuration need to be set up as well? I've tried setting that up a few different ways, all of which are throwing some kind of error.
What should I try next to get it to work?
Thanks!
As a common practice, source control such as git are used to commit only source code and resources file. Eclipse project related files are not maintained in git repo ,as those may differ for different developers. So you don't get a run configuration when you import a git project.
In eclipse Run configuration is saved in file
yourWorkspace\.metadata\.plugins\org.eclipse.debug.core\.launches
If you can get this file from other users, then you can save it in directory:
yourproject/.settings
Otherwise, I am afraid you will need to create a new Run Configuration

How to ignore library project from Git pull?

I am a newbie in dealing with Git. I am using Git in eclipse.
My main project contains the google-play-services_lib has a library project.
Recently I did Git -> Fetch from remote repository and now when I do Git -> Pull in main project, I get conflicts in google-play-services_lib which I never changed (generated files changes).
I want to ignore the library project changes from Git pull in eclipse.
Whenever I take Git pull from main Project, I always get the following conflict in eclipse-
Checkout conflict with files:
google-play-services_lib/bin/AndroidManifest.xml
google-play-services_lib/bin/R.txt
google-play-services_lib/bin/google-play-services_lib.jar
google-play-services_lib/bin/jarlist.cache
So though these conflicts are system generated changes, I always want to ignore them.
I used Team -> Disconnect on google-play-services_lib, but this only disconnected me from Git for the library google-play-services_lib.
I used Team -> Ignore on google-play-services_lib, but this did nothing in resolving conflicts.
I used Team -> Untrack on google-play-services_lib, but this added all files in google-play-services_lib in the conflict state.
Try the Options Assume unchanged and Assume changed:
Assume Unchanged to all of the generated files
Pull
Assume Changed to all the generated files
Because this will get very annoying if you have to do it for every commit, you could write a Script to handle this. The required commands are:
git update-index --assume-unchanged <file>
git update-index --no-assume-unchanged <file>

Eclipse synchronization ".classpath" differs from repository

Eclipse acts as ".classpath" edited, and puts it in synchronization tab.
When I try to commit that into the repository on SubVersioN, eclipse gives multiple errors. I use jdk 1.6 and maven with Java. When not committing that .classpath thing, there is not any single error. I can commit my other class files succesfully.
Does anyone know how to deal with it?
How can I tell Eclipse that, ".classpath" is not edited or changed?
To make my comment an answer:
Eclipse handles all project's meta files itself. There are several actions that could lead to changes in the .classpath or even in the .project file. Most likely changes in the POM.
Errors when trying to commit such changes are most likely due to having a lower local SVN revision than the repository or due to conflicts. For both, do not use the synchronization perspective, but first do an SVN update (rightclick your project -> Team -> Update). If there is a conflict, you will be notified and must solve it. If there is no conflict, you should be able to commit changes, now.
For the future:
I always recommend to not put IDE specific files into version control. This way, each developer can choose whatever IDE he wants to use (if any at all). You also could work from command line (which CI systems do, for example). Using Maven and the M2E plugin in Eclipse is very easy: Checkout the project and afterwards configure it to be a Maven project. No need to have the Eclipse meta files under version control.
If you want to change it right now, do the following:
Remove the Eclipse meta files from the project folder. Commit that
change. I recommend to directly operate on the SVN repository (using
a repo browser, for example) or to checkout to another place, do the
changes there, and commit.
Do an SVN update your project in Eclipse. This will remove the meta
files. Update your project and then convert it again to a Maven
project (see above).
Last step: Ignore the meta files, so that they will not be committed
again. This can be done with Eclipse itself or with the svn:ignore
property (we do the latter).

Eclipse setup for git project

There are quite a few questions on this topic, but there are no satisfactory answers unitl now, e.g this.
I'm using Eclipse Kepler (20130529-2219), with ME2 (1.4.0.20130601-0317) and Eclipse Git Team Provider (Java implementation of GIT 3.0.0.201306040240-rc3). So I started with great expectations after reading how great git is.
Firstly, I opened an existing project and removed all the .svn rubbish and commited it to a local git repository. Perfect - now it is time to push the files to a remote repository. After having some problems creating the known_hosts file on Windows the push was successful.
Now the problems started: I wanted to pull changes for the repository, but "... not configured for pull". OK, here it was discussed that this is a common issue, and you have to delete the project and then reimport it from a remote server to allow pulling.
Hence, I set up everything again and pulled the project. Until now I was always told that .project files should not be commit to version control, therefore I didn't include them. The "import -> import from git -> local"-menu does not recognize the files in the repo as a Java project. I can therefore only import the project as a general project or use the project wizzard and set up a new Maven project, which is stupid because all information already exists in the POM.xml. If I do a plain project import, Eclipse does not know that it is a Java or Maven project and throws tonnes of errors.
Question (skip detailed problem): Is there some less awkward way to import a Maven and Java project from a remote git repo when no .project file exists?
Easiest solution: do include the .project (as in this answer) in your git repo.
And do include also the .classpath, since you now can reference relative paths in it, instead of absolute path: see ".classpath and .project - check into version control or not?"
I found an alternative to keep .project file out of Git version control. As you said the pom.xml file should be enough for IDEs to figure out that a maven project it´s in place (and it is).
Let's say you have pushed your project into Git (without .project file) and now you want to import that project into Eclipse.
Make sure you have the Git repo added into Git perspective
Go to J2EE Perspective and double click on an empty space on Navigation View. Import -> Existing Maven Projects
Browse to your Git repo location and voila! Eclipse should catch all pom.xml files and determinate they are independent Maven projects
In my case this worked to pull multiple projects located at one same Git repo, each of them only storing pom.xml file (and no .project at all)

Categories