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
Related
I am trying to push my eclipse maven project to my GitHub repository but the folder structure it is mapping is wrong.
My Maven Project is named DocOcr and i am trying to push it to DocOcr repository on GitHub using Egit in Eclipse. Although it is copying files but its creating one more folder under gitub DocOcr repo named DocOcr and copying all files under it.
Now my pom.xml and src are getting copied to GitHub as {myusername}/DocOcr/DocOcr
i want my pom.xml and src to get copied to {myusername}/DocOcr/.
Can someone please help ?
Double-check where your .git is located locally: it should be in the same folder as where your pom.xml is.
If it is not, backup that .git (in case you have done multiple commit), and see if you can initialize a new one where your pom.xml is, and import it: re-share your project as described in "How make Eclipse/EGit recognize existing repository information after update?".
Or, as described in "When I commit a project an extra project dir is created", create the Git repo with the option "Use or create repository in parent folder of project" enabled, at the very top of the "Configure Git Repository" dialog (Team -> Share Project... -> Git)
Which is exactly what I meant by "it should be in the same folder as where your pom.xml is."
I'm struggling to create a repository for my Maven project in Eclipse. Whatever I try it turns out like so:
\ProjectA
----\.git
----\ProjectA
--------\src
--------\pom.xml
While I'd like it to be like so:
\ProjectA
----\.git
----\src
----\pom.xml
Is there any way for it to not create a separate folder under the working tree?
I'm not sure if it is the only or the best way, but creating empty repo from git directly then moving files and reimporting in Eclipse did the trick.
In case anyone needs this later:
In folder you want your repo in:
git init
Copy your sources and pom.xml and other needed files there (I also recommend creating .gitignore file at this point), then:
git add --all
git commit --m "Initial commit msg"
Then open Eclipse, delete your project and reimport it as existing Maven project directly from your repo. In my case it already recognized repo as well.
From my understanding, you are trying to create a Git repository with a single Eclipse project, located at the root of the work directory.
open the EGit Repositories view and select the Create a new Repository action
enter the name of the directory in which the repository should be created and select Finish
make sure that auto-sharing projects is enabled (enabled by default, in doubt, see Preferences > Team > Git > Projects)
open the New Java Project and enter a project name
uncheck Use default workspace location and enter the exact same path as the repository work directory (see 2.)
go to the Package Explorer, select the new project, open the context menu and select Configure > Convert to Maven Project
The detour of creating a Java project first and then converting it into a Maven project seems necessary because the New Maven Project wizard apparently always adds the Group Id to the location path.
Creating a default project in goclipse creates a folder structure with bin, src, and package. I remove the src folder and do a git pull from my remote bare repo and rename it to src. I then delete the project from goclipse and recreate it hoping that it will give me team->commit options on that folder, however the folder is not listed in the workspace.
For Eclipse work with Git, I define/ or import the project from it's location within the local Git repository.
For example, my Eclipse workspace is C:\WS (short to type, productive!).
I then also have a "Git local repository/ workspace" at C:\WS Repository to suit Git's way of working.
I'd suggest you pull the remote project into your local Git workspace & then do something like File | Import | Projects from Git.
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'.
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