Why are there different types of "Team" menus with EGit? - eclipse

What dictates which type of team menu shows up for my project? Is there a way to switch between the two?
very traditional git-ish (ie. without "Synchorize Workspace" option)
eclipse team-ish (eg. with "Synchroize Workspace" option)
Update
My git repositories view shows the following:

Using the following steps I have enabled the "Team" features for my project:
delete project in Eclipse
delete project on filesystem (including .git/ repository data)
clone project into filesystem
add local repo to "Git Repositories" Eclipse view
in Eclipse, invoke an "Import Projects..." on the newly added repository, and "Import as general project"

The second menu should be in effect when you have:
Configured Upstream fetch
Configured Push to Upstream
That is when your local repo knows what to fetch from or push to your remote repo.

Related

Remove git repository from Eclipse

I added a git repository to my project and then I hit Team > Disconnect. How do I remove this repository completely? I'm trying to set up a new git repository on my project, but I keep getting an error message.
In Eclipse go to Window > Show View -> Other... Then select Git > Git Repositories. A view with all your Git repositories should now be visible. Right-click on the repository you want to remove and select Delete repository.
Eclipse will now ask for a confirmation and give you the option to remove all repository data.
In Eclipse Neon you can also delete a repository by hand (via the OS). In that case the repository will simply disappear in the Eclipse Git Repositories view. This is not recommended for older Eclipse versions!
If you just want to remove the repository from the Eclipse but not want to delete the data from your computer, follow these steps :
First switch to Git perspective (Window - > Open Perspective -> Other -> Search for Git)
In the Git Repositories section, right click your repository and select Remove Repository from View. This will prompt you to confirm if you want to remove the projects that are imported in Eclipse from this repository. Click Yes and you are done.

How can I start a project on GitLab repo with Eclipse?

Good morning.
I just create a GitLab private repo to work in a project with some people. When I add GitLab repo to Eclipse, it says there aren't projects (and it's true). I would know how to create a project and sync with online repo so other members can see my project and codes.
I tried to start a project in git\repoName\ folder, then right-click and choose Team->Commit, but changes wouldn't save (in gitLab repo's website, it says "Repo is empty").
I tried to follow some online guides, but without success.
Sorry for bad english!
Eclipse 4.2 and newer, comes default with (E)Git installed. There is a good Eclipse git tutorial from Vogella.
Create a GitLab git repository
Log into GitLab
Create a project / git repository
Copy the https url from the project, used for cloning
Adding an GitLab git repository in Eclipse
Open the Git perspective in Eclipse
Use Clone existing Git repo, as shown in Using git repository view
Now all the git functionality from Eclipse can be used.
I assume you have a cloned repository available in Eclipse (eGit) that is empty. If not, follow the steps in the answer from Verhagen.
By now, you have a cloned repository that is marked with "[NO HEAD]", indicating that no commit has been made.
Start creating a new project by using your project type of choice; I'll use Java project for simplicity: File menu > New > Java project
in the New Java Project wizard un-tick the "Use default Workspace location" checkbox; instead, choose the directory where you cloned your empty GitLab project, and append the name of the project (this is to make Eclipse create a directory inside the repository, just in case you later want to create more projects in the same repo).
Fill in the wizard as you usually do. When you are done with the different steps, you'll have a new project, that is also marked with "[NO HEAD]"
Create some source files you want to share (e.g. HelloWorld.java)
Synchronize workspace (right click on the new project > Team > Synchronize workspace) you will see that now there are files to commit. Pay attention to those files, since some of them ( .gitignore, and maybe .classpath, .project,.settings directory... depending on how you share your projects) you'll want to add to the .gitignore.
right click on the files you want to commit, fill in the commit message and click "Commit and Push". Click Next
Since it is a new repository, you'll have to configure the Push action. I selected HEAD as source and HEAD as destination. You might want to do the same, at least for this first commit+push; later on, you might choose to add some specs for branches, etc.
The Push Confirmation will show you that the new branch master:master will be created.
Both project and repository lost the "[NO HEAD]" marking
You can check gitlab site to confirm your files are there.

How to properly use EGit with Eclipse

The only way I seem to be able to get use git in eclipse is to create a non-git project then turn that into a repository. This ends up moving the project out of the eclipse workspace on the file system. I then have to delete the project(it's still in the git repository), then import a git repository after creating a branch and clone it to get it back into the eclipse workspace.
Is there a simpler way?
I simply want to create project that is really a clone from a local repository. Essentially I have two copies on my HD but I can commit the eclipse project to the git repository. Unfortunately there has to be a better way?
To answer this question involves three steps.
Create a external (remote) repository
Share the project in a way that it remains in the workspace
Connect the project repository to the remote repository
Create a Remote Repository on Your Local Machine
Switch to the Git perspective. Click on Create a new Git Repository.
When a dialog appears select a directory where you would like your remote
repository to be. This is were your project will be pushed to. You will also
want to select the Create as a bare repository option.
That's it for this step. You should now have this repository in your EGit
repositories list.
Sharing Project within the Workspace
There are two ways to share a project so that it remains in your workspace.
1. Make the project directory a repository
2. Make the whole workspace directory a repository
The Project as a Repository
The first option option is not recommended by the Eclipse team. This issue is
described in more detail at Why is not recommended to have an Eclipse project folder as a Git repository?.
The basics of the issue are twofold:
You can't have more than one project per repository
If some thing happens to your workspace you'll lose your repository too
Issue 1 isn't solved here. Issue 2 can be solved by connecting to a remote
repository as show later.
To share the project as a repository:
Right click on the project
Select Team -> Share Project... from the popup menu
Click Use or create repository in parent folder of project
Select the project from the list
Click on the Create Repository button
Click the Finish button
Next you'll want to connect your newly created repository to the remote repository.
That's covered below.
The Workspace as Repository
The second options allows multiple projects to be added to your repository.
In fact any new project you create will automatically added to the repository.
Automatically adding projects can cause some issues.
One issue is that, if there are changes in multiple projects, staging
those changes can take a bit of wading through. Using a Tree presentation when
staging can simplify things.
Another more serious issue occurs when importing a git clone of a project into
the workspace. This importing will create nested repositories. Nested
repositories can cause problems
according to this post.
By default Eclipse doesn't import the git clone of the project into the workspace.
To share the workspace as a repository:
Right click on the project
Select Team -> Share Project... from the popup menu
Click on the Create button
Select your workspace as your Repository directory
Click the Finish button
Once your repository is created you may want to do a little house keeping. I suggest
adding the RemoteSystemsTempFiles project to the .gitignore file. Note: the
.metadata file is added automatically by Eclipse.
You can ignore the RemoteSystemsTempFiles by:
Switching to the EGit perspecitive
Selecting the workspace repository from the list of repositories
Select the Git Staging tab
Click on the View Menu button on the right side the the tabs toolbar
Select Presentation -> Tree menu (folders are easier to ignore form the tree view)
Right click on the RemoteSystemsTempFiles project
Select the Ignore Folder menu
Ignore other projects in the same way
Connecting to the Remote Repository
The last stage is connecting the workspace repository to the remote repository
we created earlier. Once you've switched to the EGit perspective:
Expand your workspace respository
Right click on the Remote node in the tree
Select the Create remote... menu
Leave the remote name as origin
Select Configure fetch
Press Ok
Click on the Change... button
Click on the Local File button
Select the bare repository that you created in the first section
Click Finish
Click Save and Fetch and then Ok
You can then stage, commit and push changes in your projects and workspace.
When you first commit and push EGit will push the default branch master
to the remote and configure pulling this branch from remote repository.
Follwing the User Guide, you would need to create the .git repo within your current project path:
If the .git path is within the current project path, there is no reason EGit moves your files anywhere else.

How do I reconnect a moved git repository with it's original project in Egit?

I have a number of projects within an Eclipse workspace. One project is connected with a git repository. This is the original directory/project structure:
Eclipse_workspace
Eclipse_workspace/Project1
Eclipse_workspace/Project1/.git
Eclipse_workspace/Project2
After reading about the complications that can arise from keeping a git repository within the parent directory of a project in a workspace (here), I decided it would be best to move the repository outside the workspace. Here is the revised structure:
Eclipse_workspace
Eclipse_workspace/Project1
Eclipse_workspace/Project1
Eclipse_workspace/Project2
.git
.git/Project1
Within the "Git Repositories" view I re-added the repository. I thought it would be simple to reconnect the repository to "Project1" by altering a few file path settings. I found that this was not possible from Project1's properties (right click on project -> properties). I noticed that within the "Share Project" wizard you can connect to an "existing repository". So I disconnected the project from the now non-existent repository and I tried to reconnect it using the "Share Project" wizard. But although the repository is shown in the "Git Repositories" view, I was unable to select it. I clicked the "create" button and tried typing in the file path but this gave me an error stating that the directory is "not empty".
So I have now become stuck as there seems to be no other options available. How can I reconnect this repository? I'm surprised by how complicated this is, I must be doing something really obviously wrong. I really need to get on with some work and messing around with Egit is taking up all of my time.
I ran into this same problem and here was my solution:
Copy your repository(including the .git directory and the working directory) to wherever your new location.
Add your new repository in the "Git Repositories" view in eclipse.
Then import your "Projects from Git".
The point is: try not to reconnect, just import the projects from your new repository into your eclipse workspace.
Hope this helps.
Select your project(If you have many projects don't forget the clic to the right one)
*clic right -->team -->Share project
Go to your project directory
open a console - type cmd
run git init
check your branch with - git branch
change branch - git checkout
note:
You need to have a git tool installed in your computer.
it worked for me.

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.