Search code examples
eclipsegitlabegit

How to fix the structure of the project on GitLab?


I have a problem with my project in Eclipse IDE. For the first time, I worked on an old version and made several changes.

I tried to upload the project on GitLab for the first time I configured Git on Eclipse IDE and I tried to commit and push "but I could do that only after doing a 'Fetch' from the remote branch and commit the 'Merge' change in my local repository.

Because I got this error:

rejected non-fast-forward

I followed this link Egit rejected non-fast-forward to fix it.

The fetch downloaded all the git project files in my project on Eclipse. Until now in my project, I have a subfolder like this: myProject/myProject.

I made several commits and push and it works normally. I figured out that a subdirectory in gitLab docroot is created with every push I make.

This is the local project structure:

structre_eclipse_project_problem

This is the project structure on GitLab:

structre_project_gitlab

I want to delete docroot/WEB-INF/classes from GitLab.

How to delete this commit from GitLab using git plugin in Eclipse and how to correct my local project structure?


Solution

  • docroot/WEB-INF/classes is a folder. Git does not track folders, only files:

    1. To delete a folder, you have to delete all the files in it.
    2. In the Git Staging view, commit the deletions.
    3. Make sure your current local branch is configured as When pulling: Rebase (in the Git Repositories view right-click the branch and choose Configure Branch...)
    4. Git > Pull to make sure your commit is the latest commit in the upstream branch. If there are conflicts, you have to resolve them in the Git Staging view
    5. Git > Push to Upstream

    For details see the EGit User Guide and be aware that old Stack Overflow answers refer to outdated version of EGit.