Egit adding Eclipse project folder to git repository

前端 未结 1 1477
后悔当初
后悔当初 2020-12-29 11:43

I\'ve created a new empty git repository on BitBucket and now I want to link it to Eclipse.

I added the repo to the \"Git Repositories\" view and created a new proje

相关标签:
1条回答
  • 2020-12-29 12:39

    From the EGit Eclipse Wiki page:

    It is probably not a good idea to make a project the root folder of your Repository

    The reason is that you will never be able to add another project to this Repository, as the .project file will occupy the root folder; you could still add projects as sub-folders, but this kind of project nesting is known to cause lots of problems all over the place. In order to add another project, you would have to move the project to a sub-folder in the Repository and add the second project as another sub-folder before you could commit this change.

    I know this is not a solution, but at least this gives a valid reason for having to endure the additional folder with the same name.


    The (not recommended !) workaround

    Create/modify the remote repository, then clone into a new local project:

    If you haven't started developing yet or can afford to move the contents of the duplicate sub-folder (in your case, "My Long Project Name") to the root of the git repository, you can avoid ending up with twice the same folder, by going the other way around:

    1. Move the files within the project to the root of the remote repository / Create the remote repository if this is a new project.

    2. In the "Git Repositories" view in Eclipse, find the "Clone a Git repository and add the clone to this view". Follow the steps to clone your repository from your URI to a local folder.

    3. In the same view, right-click the repository in the list and choose "Import Projects..."

      • If you have a .project file in the root folder, i.e. the files where already part of an Eclipse project, choose "Import existing projects" and choose the root folder, then watch Eclipse do its magic.

      • If this is a new project (or the files on the origin are not an eclipse project), choose "Import as general project", then modify the project type in Eclipse afterwards if you need a specific project type.

    Disclaimer: I personally decided not to use this workaround and to stick with the EGit recommandations.

    0 讨论(0)
提交回复
热议问题