Importing projects in a BitBucket repository into Eclipse - eclipse

I have a BitBucket repository that contains a directory of Eclipse projects, and I am having trouble importing those projects into Eclipse.
The files contained in the repository came from a Subversion repository. They were converted to a Git repository in the usual way, associated with the BitBucket repository using "git clone ", and the BitBucket repository was populated using "git push -u origin master". The Source tab of the repository in my BitBucket account shows all of the files that were contained in the original Subversion repository. To verify that the BitBucket repository was set up right, it did a "git clone " to a different local directory and verified that the new directory had the same files as the directory from which the files were pushed to the BitBucket repository.
Within this repository is a directory containing several Eclipse projects, and I need to import them into Eclipse. To do this, I installed the EGit plugin into Eclipse, switched to Eclipse's Git Repositories view, clicked "Clone a Git repository", entered the url of my BitBucket repository, specified my Workspace directory, and check a box labeled "Import all existing projects after clone finishes". When the clone and import were finished, all of the Eclipse projects were displayed in Eclipse's Package Explorer panel.
Some of the projects display all of their contents correctly, with a project folder containing, among other things, a src folder containing nested package folders that contained Java source files.
The problem is with the other projects, which display a project folder with a greater than ('>') sign between the folder icon and the project name, and a src folder with a greater than sign between the folder icon and the string "src". This folder contains no package folders and no Java source files. Eclipse documentation and forums say that these '>' signs are displayed when a file has been changed since it was last synchronized with a repository (although they mostly talk about these '>' signs being displayed for individual files, not for folders). I tried using the Eclipse command 'Team -> Synchronize Workspace' to make sure that the folders were synchronized, but it didn't change anything. Could anyone tell me what I did wrong along the way that prevents these projects from being imported into Eclipse correctly?
Thanks,
Mike

Related

Egit: How to create a git repository that is in a separate folder from the project workspace in Eclipse?

In Eclipse Oxygen, I created a project called testproj at c:\jwork2019\testproj\. My workspace is at c:\jwork2019\. The project's folder has the content of
c:\jwork2019\testproj\.settings\
c:\jwork2019\testproj\src\
c:\jwork2019\testproj\.project
I would like to create a git repo for the project, located at a separate repo directory at c:\jrepo2019\. I successfully created the empty repo c:\jrepo2019\testproj\.git\. I want it to track all the project's files located at the workspace at c:\jwork2019\testproj\*.
I have successfully created the project and the empty repo via Eclipse and Egit.
The problem is when I tried to Configure Git Repository of the project by right-clicking on the project and then Team -> Share Project..., I could select the repository created, but it changes/moves the project's folder location from my workspace at c:\jwork2019\testproj\ to c:\jrepo2019\testproj\testproj\.
I would like the project workspace directory stays in c:\jwork2019 instead of moving the project directory to the repository folder c:\jrepo2019\....
I am guessing that I can do that via git command line by just git add c:\jworks2019\testproj\*, but I don't think I have the git command line installed, I only have git on Eclipse.
I found the question Can I store the .git folder outside the files I want tracked? that has the same goal. But it does it on linux command line.
Is this achievable in eclipse? And how can I do what I wanna do? Thanks

Eclipse EGit changes folder names after Pulls

I'm having trouble using EGit - specifically when pulling.
Basically, I cloned a Git repository in Eclipse using "Clone a git repository and add repository to this view" in Git Repositories view in Eclipse.
After that, I imported the Git project and used the "import using existing Eclipse project tab".
However, this changes the names of the packages. Instead of having a src folder that contains all the packages ("Model", "Controller", "Player" etc), it changes all the names to the packages to "src.Model", "src.Player" etc.
This is what the remote repository looks like
And this is what happens when I import the git project:
Because the package names had changed, it would compile. So initially I changed the package names back to their original (src.Player -> Player). However, when I pull, it changes all the package names to start with src.
Is there any way I can fix this?
Thank you
Your project folder instead of src is configured by mistake as a source folder:
In Project > Properties: Java Build Path, in the tab Source remove the project folder and add the src folder instead.
Commit and push the file .classpath which stores this project-specific setting

Connect existing Eclipse project to existing Git repository

I have an Eclipse workspace in ~/EclipseWorkspaces/Sabia with a number of projects under Ubuntu 15.10. The source code for these projects resides in a Git repository at ~/GitRepositories/Sabia.
I can find no way to tell Eclipse in the Pydev Package Explorer that the projects use the Git Repository. If I try to use Team->Share, the system rejects the Git repository because a directory for each project exists in the repository and Eclipse is trying to move the project to the repository which already has a project directory.
I tried the suggestion by Michal Grzejszczak but unfortunately it does not work because the Git Repository does not contain complete projects, only the source trees for the projects. The Eclipse metadata is in /EclipseWorkspaces, not in the Git Repository so import projects on the Git Repository perspective does not work.
In addition when I tried to delete the projects I got the following error message:
AppFrame (One of my projects) contains resources that are not in sync with /home/jonathan/Dropbox/EclipseWorkspaces/Sabia/AppFrame. Press 'Continue' to force delete`
for half of my projects.
Unfortunately the message gives no more information and I have no idea what kind of problem might actually exist. I am not prepared to delete any flawed projects until I have corrected whatever was wrong.
How can I tell the Eclipse Pydev Package Explorer where the Git repository resides?
You need to first add this repository to Git repositories view in Eclipse. Then remove these project from workspace, but without deleting contents and then the most crucial part import them back with "Import projects..." from context menu after right clicking Working tree of the repo in Git repositories view.
That should make your projects managed by Git.

Git workflow: PDT + Egit on Eclipse workspace and Git bare repository

I'm developing a Symfony applicatoin and I'm trying to set up a Git workflow on Eclipse. The workspace (where the project files lies) are located on /home/sfprojects/testing/ and the Git repository is located on /var/git/testing.
Reading over and over all the Git resources I've could found (including "Pro Git" by Scott Chacón, and the EGit user guide (http://wiki.eclipse.org/EGit/User_Guide, among others), it's easy to understand why the Git repository and the Eclipse workspace should not share the same directory, now my big confusion is that I can not see a method to keep both things separated from each other.
Once I've created the Git repository through the wizard, all the project files are moved automatically from the Eclipse workspace to the working directory on /var/git/testing/testing/. For my big surprise, the new created Git repository became into the new project workplace on Eclipse with .git directory in the parent directory. It is not a obvious contradiction?. If I let the mouse pointer over the option "Use or create repository in parent folder of project" a very clear help tag with the following text:
When checked, this wizard will try to find or create a repository in the parent folder hierarchy of the selected projects.
Typically, newly created projects are located in the Eclipse workspace, thus repositories created this way would also end up in the Eclipse workspace.
This is not recommended for several reasons explained in the EGit user guide.
So, after some research, my logical conclusion is to create a Git bare repository and then link it to the project located in the workspace... wrong! bare repositories are not available to a Eclipse project.
I need a serious explanation on this.
Seems that I went wrong about what I thought was a contradiction in the EGit User Guide and the EGit behaviour about moving the project directory to the Git repository.
When the project files are moved as a working directory of the Git repository (with a Git metadata folder at the same level), they're still under the Eclipse control, as Eclipse workspace. But as EGit User Guide says (http://wiki.eclipse.org/EGit/User_Guide#Eclipse_Workspace_and_Repository_working_directory), the .git metadata folder should NOT be into the workspace... well that's when I was wrong, cause it is a Eclipse project/Git working folder... but it IS NOT an Eclipse workspace by any means, so the Git metadata folder is not editable, as any other source project file, just for Git (and the EGit Eclipse plugin, of course).

Eclipse - Exclude root directory from git repository?

I'm trying to setup a git repository for my Eclipse project using EGit. However, I'm having trouble excluding the root/project directory from the repository. That being, my project has the structure:
ProjectDirectory
src
war
etc
I would like the repository to contain src, war, and etc, but not contain the parent directory ProjectDirectory. That's because if I want to clone a copy of the project in my workspace, ProjectDirectory2, the repository for the second project now will try to create a second root directory, ProjectDirectory. Unfortunately, when I try to add a repository for a project using EGit, I seem to only be able to use Team > Share Project on the project folder itself and I don't seem to see anyway to exclude the root directory in the repository from within Eclipse.
Any suggestions on how to skip the top directory in the repository using EGit? I'd prefer being able to do everything from within Eclipse, but if there isn't a way, is there a way to setup the repository this way outside of git, then still be able to use the git control regularly from within git on the repository skipping the top level directory? Thank you much.
Short answer is It is POSSIBLE with EGIT + M2E
trick is when doing share project -> in the configure git repo window
making sure use or create repository in parent folder of project is ticked
and making sure click create repository button
the main aim of this is to create the .git folder in you project root
not above your project root.
Here's my solution. Though not particularly elegant - the steps are all simple, it works, and can be done in about 10 minutes:
Clone the remote git repo into your local filesystem .. e.g.: ~/git/project_repo_root
Create your eclipse project as usual .. e.g.: ~/workspace/eclipse_project_root
Delete the project from eclipse (but not filesystem!)
Open file manager and move the eclipse project you just created from ~/workspace/ root into ~/git
mv ~/workspace/eclipse_project_root ~/git/
Move the .git/ folder from the repo folder to the eclipse project root folder:
mv ~/git/project_repo_root/.git ~/git/eclipse_project_root
Using a shell go into /eclipse_project_root/ and do the usual command line commands for all files you want in the repo:
git add <abc>; .. commit; .. push
Return to Eclipse and go to Git Perspective, and click "Add an existing local Git repo to this view". Select the git repo you are working with and the view should be updated with an entry for that repo once you say ok.
Once you see the local repo in your view, you can right click it and select Import Projects
Go back to your main development perspective (Java, etc) and you should see the project there with the Git markup on the root node in package explorer view.
~~~~~
At that point, you should see the eclipse project folder you had just moved (to ~/git in the examples described here)
I realize this is more verbose than I would like my answers to be, but for this particular challenge/solution .. I don't know of a more straightforward way to do it.
And as for the post above that describes you should always include the eclipse project root directory .. the reality is some projects/clients/etc require that the git repo not contain the root folder. So a solution like this is necessary sometimes
You should commit the project root for multiple reasons:
If you commit only sub directories of your project, you will miss files and folders which are hidden below the project root (e.g. the .settings directory and others). Those need to be committed also, otherwise your project is going to miss information and may not lead to the same results on another machine.
Your wish of trying to clone the same repository a second time in the same workspace sounds very much like you should re-read about git branches. In git, switching between branches is done after a blinking of the eye, so branches should be used when working on different features, versions or otherwise different editions of your project.
The Eclipse project name and the underlying folder name on disk do not need to be the same (watch out for the checkbox "use default location" when creating a new project). So you can checkout a second clone of the project with a different name.
If you later add more projects to your workspace (e.g. a test project), you cannot easily share them into the same git repository, as the content of those additional projects would mix up with the sub directories of the first project in the repository.
If you have maven project you would typical like to create a repository without the project folder created by egit. For my experience this is not possible with the egit plugin.
But it can be easily done from the git command line.
First move your existing eclipse/maven project from your eclipse workspace into your git folder (this is what also the egit plugin did):
mv myproject ~/git/
next create a new git repository
cd ~/git/myproject
git init
Now create a .gitignore file and place it into your new repository folder (~/git/myproject/.gitignore). This is an example for a .gitignore file:
# ignore all bin directories
# matches "bin" in any subfolder
bin/
# ignore all target directories
target/
# ignore all files ending with ~
*~
# ignore eclipse directories and project files
.settings/
.project
.classpath
Finally initalize your new repository with the content of your project
git add *
git commit -m "My initial commit message"
Thats it.
Now you can restart your eclipse and reimport the project from your new git repository.
Go into your eclipse egit repository view and coose 'import exisiting project'.