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

12,411

I ran into this same problem and here was my solution:

  1. Copy your repository(including the .git directory and the working directory) to wherever your new location.
  2. Add your new repository in the "Git Repositories" view in eclipse.
  3. 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.

Share:
12,411
Jonathan
Author by

Jonathan

Updated on June 04, 2022

Comments

  • Jonathan
    Jonathan about 2 years

    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.