How to import projects properly using Git from cloud - eclipse

How to properly import projects from BitBucket or another cloud repository? I have Eclipse Neon JavaEE. Even if there is Git preinstalled yet and (for my purposes important) Maven too. The imported projects are not real projects.
The straighforward way is:
File -> Import -> Git -> Clone URI (copied from repository i.e.
BitBucket)
Fill in username/password if needed
Next
Now I can see this picture (Ubuntu Linux 16.04)
But no any from this options clone huge of projects properly.
To successful clone projects I must in this moment
Cancel process (cloning is in local repository yet)
and manually add projects one after another one into workspace in Git Perspective on expanded Working tree using
Right click on projects -> Import Projects...
Do you know anybody how do this operation better?
Next another thing is, that I cannot select more projects, because the option Import Projects... will disappear.

Another approach is to:
clone those repositories manually in command-line (with a Git you install yourself, separately from the one used by Eclipse).
Clone those repo in any path you want, outside of the Eclipse workspace folder.
import the project you want into the Eclipse workspace, by using the local path where the Git repo has just been cloned.
once imported, select the Team/share option by right-clicking on the imported project in Eclipse: it should recognized the project is already shared as a Git repo.
That wy, you don't try to do everything with Eclipse in one Go: you separate and keep better control on each step (clone, import, share)

Related

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 pull successfully but not shown in eclipse

I have a project imported from git repository to eclipse. The thing is, when others made changes from their parts (kind of structure changes of the package and class folder structure), I used git pull and it worked properly.
The thing is, the change is shown in my local repository but not in eclipse. I don't how to make eclipse update.
Even though i delete the project from eclipse and reimport again but still didn't work
You need to import these new changes into your eclipse workspace after git pull.
In Git Repositories view go to the repository expand the the repository and right click on Working Directory then select Import projects.. then a wizard will appear follow the instruction.

Importing an existing maven project with a .git subdir

I have a maven project. I've been using the command line to perform git operations. (I ran git init inside the project so there is a .git subdir in it)
I push it to a bare repository from which I sync via various computers.
One project, one repository; just like thousands of repos on github.
I decided to try egit to manage git from Eclipse even though the command line works just fine.
Ok, right click on the maven project, Team->Share Project, Choose Git, next.
I don't want to create or use a repository in the parent folder - or create one; it already is a repository.
Import Git project barfs on bare repositories, so I can't just "go to the source".
What is the simplest way to import an existing git project?
(I guess, cd to a working dir, clone the bare repo, add that to eclipse as a repo, then import from there - but make certain your run mvn eclipse:eclipse first since git's import isn't as kind and the maven project import.)
eGit is not intended to work with bare repositories but to make Eclipse aware of the fact that the various files in the workspace have a VCS behind them and to reimplement enough of the git functionality in pure Java for this to work without a native client.
Therefore clone your repository, and work with the clone. I have found that these steps work well with m2e.
clone the repository
File -> Import -> Existing Maven projects
After the import finishes and the dependencies downloaded, use right-click Team -> Share on all projects, choose Git, and check the topmost checkbox so it looks for .git.

Importing multiple maven projects from git into eclipse

I've got a git repository with two Maven projects "foo" and "bar". The structure of the cloned repo is as follows:
myrepo
.git
foo
pom.xml
bar
pom.xml
What I want
Two projects "foo" and "bar" in my workspace with maven nature and working Team menu.
I'm running Eclipse 3.7 with m2e 1.0.0.
I tried the following:
Import -> Check out maven projects from SCM
This clones the repo into a new folder in my workspace folder and imports the two projects, but without connection to git (Team menu is mostly empty).
Import -> Projects from Git
With this option I can only import the entire repo as a single general project (with working Team menu). If I then use "Import -> Existing maven projects", the projects foo and bar are imported but without working Team menu.
Is it possible at all to import multiple projects from a git repo with working Team menus?
As far as I know and are able to perform on my setup (Eclipse 3.7, Egit 1.0.0, m2e 1.0, m2e-egit 0.13), it is not possible in a single step.
The cleanest procedure that I know of is the following:
Clone your Git repository (preferably from Eclipse, otherwise you also need to add the repository to the Git Repositories view);
Import -> Check out existing Maven projects from the root folder of your cloned repo;
Select all the resulting Eclipse projects, and choose Team -> Share project;
Now select Git and check Use or create Repository in parent folder of project.
Long-winded? Sure. But cloning beforehand gives you control over the folder name you check out to, in contrast to Check out Maven projects from SCM which on my machine produces a "maven_{unix_timestamp}" like folder name.
I agree wholeheartedly with you that a quicker procedure should be available.
Here are the steps I used (using eclipse helios, egit and maven plugins)
From git repo perspective, clone your repo (I'm pulling in
git://git.springsource.org/spring-security/spring-security.git for
example)
Use "Import -> Projects from Git" to import as single
general project.
On this project use "Import -> Existing Maven
project" to import separate subprojects.
On each new project, go to "Team -> Share Project ->
Git".
If desired, remove the original project imported in step 2 above. Just remove from workspace, don't remove disk contents.
Create Clone of your Git repository. This can be done by choosing option of clone in'Git Repo Perspective' in eclipse. It will create a local repository in your system. I used bitbucket (GIT) to host my code. It will create a repository with the same name as you have given while creating the repository at your host. At this point of time an empty repository will be created since I have not put anything at host as of now.
Now copy your multimodule Maven project to the local repository which is created in step 1.
Go to eclipse, now click on import --> Projects from GIT -->Existing local Repository -->select your local repository --> import existing projects and we are done.
You will see '?' on your modules. Now select all the projects --> Team -->share projects-->Add index. You will see '+' sign. Now commit and push your changes.
In my case, I have not created the repository at host before hand. I created it through eclipse by pushing the code from my local to host. Vice versa can be done by cloning. If your code is already present at the host, cloning will fetch the code and save it in your local repository and similar steps can be executed to import project into eclipse workspace.

How do I create a git repository over an eclipse project or vice versa?

I have a git repository that is just a directory tree (/myprogram/src/com/mycompany/test) with some source files. I wish to create an eclipse project around this repository. Both orders of create project in eclipse and git clone <url> <myprogram> from the command line give me a "folder already exists" error from whatever tool I use last. I could move the files manually to merge them, but it feels messy and I'm not 100% confident I know which files to touch.
How is this supposed to be done properly?
You could do it by selecting Import -> Existing Projects into Workspace, select the directory containing your project (the parent of myprgram), and check the checkbox next to your project (myprogram).
To have Git support in Eclipse, install eGit and then right-click your project, select Team -> Share Project -> Git, expand the triangle to select the existing repository and click Finish. This should give you Git annotations on your project.
Another option might be to just select Import -> Git -> Git Repository (after eGit is installed) and import your repository (but I've never done that with a local repository). See also the eGit user guide.
To resolve this I just ended up copying the git repository into a newly created project, but upon revisiting the issue I found a link here that suggests something slightly more elegant (but functionally similar).
After creating a new project, use Import -> Filesystem and Select All. In my case, my repository already had a proper /src/com/... directory structure which merged nicely into the one set up by the new eclipse project.