I use Eclipse 3.7 and EGit 1.0. If I create repositories inside my Eclipse workspace (as a sub-folder for a project) everything works fine. But obviously this is not recommended so I want to build a repository in a place elsewhere. But this does not work as expected.
I make this steps:
Create a simple Eclipse project with a text file in it (myproject).
Share -> Team -> Git
Create Button -> use c:\user as Parent Directory and mygit as Name
I leave Path within Repository empty
so Target Location is c:/user/mygit/myproject -> Finish
At this point I expect that I can manage my code via EGit. But if I choose the Team menu within the project or text file context menu I see no version control options like commit etc.
On the other hand if I delete the created repository the project is also deleted.
Does anybody know how to do this correctly? At first my goal is to build a simple single user repository.
It's quite simple (my setup: Eclipse 3.7, EGIT 1.1.0). The standard layout is to put your project inside (below) a GIT repository, so that you can have more than one Eclipse project in one repository - outside the Eclipse workspace tree.
Then, we first create the repository: In the "Git repositories" view, we create a new (non-bare) repository:
For example, in the dialog we fill:
Create a new repository
Parent directory: c:\user\gitreps\ (a directory you use to store git repositories)
Name : repo1 (your repository name)
This will create c:\user\gitreps\repo1\.git\
After this we share the existing project, which will trigger a physical move:
Take your new project, (no matter where was it created, inside or outside the workspace dir) and share it:
Project (myproj) -> RightClick -> Team -> Share -> Git
In the dialog list select the repositoy you just created (repo1) and leave the rest blank.
See that the "Current location" and "Target location"
In our example, the "Target location" should be c:\user\gitreps\repo1\myproj
When you press Finish, the project will be physically moved as we want.
Related
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.
I am trying to move a project into my git repo, using Team -> Share Project -> Git, when I select the repo the error "Cannot move project x to target location...as this location overlaps with location..."
My workspace and repo are different folders (this seems to fix it for most people).
Which version of eclipse and egit plugin are you using?
For me on Kepler Service Release 2 and Egit 3.2.0 it works if I choose:
Team->Share Project->Git
and then tickbox Use or create repository in parent folder of project BUT then select the project folder . instead of the parent ..
In my case, there was a .project file inside the git repo. I just deleted it from the terminal. Then everything works perfectly. You can't access it with the GUI which is another reason why terminal is awesome!
Tried many options but they didn't work. I've posted an answer in another similar question which is a manual way to do it which will work with any Eclipse version, here is the link: https://stackoverflow.com/a/41799215/578046
I got this error when attempting to bring in a new subproject into an existing parent project in a "split" workspace i.e. the default configuration using separate workspace and git folders.
The final workaround was different from others listed:
Delete the project from within Eclipse (choose default option: DO NOT delete on filesystem)
Use the system shell move the new subproject from the Workspace location into its proper place under the parent project in the git folder structure
In Eclipse, go to the the Git Repositories view, right-click the new project folder under Working Tree, and choose "Import Projects..." to reimport the project
Re-add the project to any Working Sets it needs to be part of
I encountered the same problem, and used the following steps to solve the problem:
1、Team --> Share Project...
2、Check Use or create repository in parent folder of project,and then Check Your project...
3、Click Create Repository
4、Click Finish
I had the same problem and realized that when i cloned the git repository i selected the "import all existing Eclipse projects after clone finishes" checkbox. So i removed my repository and cloned it again without the checkbox selected. Then i had no problem sharing a new Java project into my repository (because no .project file was created on the git folder)
I had the same problem, here's how I solved it:
Open The Git Repositories View:
Window -> Show View -> Other -> Git -> Git Repositories -> Open
Then Right Click YourRepositoryName in the Git Repositories View and Click Clean...
A Popup Window will open, Tick the .project file and Click Finish
Now when you try to use Team -> Share Project -> Git it should work.
If Clean... doesn't delete the .project file, you can also manually do it by opening the repository file system in the Git Repositories View and look for the .project file then Right Click the file and Click Delete
I just went to git folder using terminal and entered the command rm .project. The problem went away.
I had a similar error once, which was caused by the name of my folder containing spaces, e.g. "Joe Doe".
Moving the project to a place where it doesn't have any space in file path solved my problem.
I've renamed my remote repository and created a new local repository from it. How do I change it within EGit in Eclipse?
Previous answer list below also has issues. The only solution appears to be:
Backup .project, etc. files
Delete existing project
Import existing local git repository as a "general project"
Put backed up files into the new project
Restart Eclipse
Rename, per se, is not the actual operation -- changing repository is the correct mindset to solving the problem according to a coworker.
Select 'Team->Disconnect'
Select 'Team->Share' On 'Share Project' dialog
Select Git and click Next
Unselect 'Use or create repository in parent folder of project'
Select the new local repository
Checkbox the project name showing correct current location and target location
Click 'Finish'
Eclipse will move existing files from previous local repository to the new local repository.
I just renamed a repository. I use LiClipse, an Eclipse variant which includes EGit. I believe there is no way to do this operation with the EGit UI. Here's how I did it outside of EGit and Eclipse, without confusing them.
In the Git perspective, right-click on the repo, and select Remove repository from view... from the pop-up menu.
A dialogue box offers to delete the repository from the workspace. I interpreted this to mean, delete the repo directory and everything in it from my disk. Press the "No" button.
In the programming language-specific perspective (PyDev, in my case), right-click on the project, and select Delete... from the pop-up menu.
A confirmation dialogue box appears. In this case, I interpret it as just confirming that I want to remove the project's entry from the project list in that perspective. There is a checkbox, "Delete this project from workspace?". Leave that checkbox unchecked. Press the "Yes" button to confirm.
In the finder or command-line, find the repository directory, and change the directory name to the new name.
Return to Eclipse, and the Git perspective.
Select menu item, File... Open projects from file system.... (There is also a small icon with a "+", above the projects list, with tooltip "Add an existing local Git repository to this view". I believe it is different but equivalent.) A dialogue box appears.
Select the (renamed) repository directory. Click Next or Finish to complete the wizard. The Repository appears in the list of Git repositories in EGit.
Return to the programming language-specific perspective appropriate for that repository.
Select menu item, File... Open projects from file system.... A dialogue box appears.
Select the (renamed) repository directory. Click Next or Finish to complete the wizard. The Repository appears in the list of Git repositories in that language-specific perspective.
The project-specific Eclipse settings appear to be stashed away in a file .project within the repository, so they are not modified by the rename happening overhead.
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.
I commit a project on github using these steps :
Right click your project, select Team -> Share Project -> Git. Select
the proposed line and press "Create repository". Press finish.
Right-mouse click on your project and select "Team" -> "Push". A
dialog pops up. Maintain the following data. Adjust the hightlighted
line so that you are using your user and your project name.
But when I view my project on github this is my project structure :
myproject -> myproject -> src
When it should be :
myproject -> src
So an extra level with the project name is being created on github. Am I commiting the project correctly ?
When I try to share the project with "Use or create repository in parent folder of project" enabled the project path is "c:\homedir\git\egit-test1\egit-test1" Should it not be "c:\homedir\git\egit-test1\" ?
Screenshot attached :
If you don't want the additional directory level in your git repository, you need to enable the "Use or create repository in parent folder of project" option at the very top of the "Configure Git Repository" dialog (Team -> Share Project... -> Git).
However, this will create the repository directly in your workspace and not in the default repository folder, which is not recommended. But you can move the project to the right place and re-import it into your workspace in a second step.
Another option would be to create the repository on github first. Afterwards you can clone the github repository and move your code into it.
i) pull code in local repository.
ii) copy code into seprate folder.
iii) delete all hidden files and .git .
iv) copy code again in your local repository.
v) commit and push