2

I'm confused how to setup my project correct. There is already a existing git repository named "DatabaseHub" which is only containing the README.md after my first commit. Then I have there my Spring Initializr zip which I want to use for this repository. I named it databaseHub as well. It's a Gradle project.

When I'm trying to create the project with this zip in Eclipse in my git project I fail.

What I tried: Cloned the git repo (so it is in the project explorer), tried to import the extracted initializr zip with the option "Existing Gradle project" but this won't work cause of the name collision.

I don't get what's the right attempt to start this. Just putting all the files manually in the repo doesn't let Eclipse know that it's even a project now.

Eclipse version is 2019-09.

CptDayDreamer
  • 1,526
  • 6
  • 25
  • 61

1 Answers1

1

Try and unzip that project elsewhere on your disk.

Then go to your local Git repository (the one with the single README) and do:

cd /path/to/local/Git/repo
git --work-tree=/path/to/unzipped/project add .
git restore -- .
git commit -m "Import project"

The git restore -- . step (with Git 2.23+, August 2019) will make sure your imported files are checked out and visible within your local repository.

Finally, import the Gradle project: Eclipse should detect the Git repository in it (if not, do a Team > Share)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thank you very much. I think many people have problems with that. I had to delete and clone the repo after the commit again because the new files did not appear in the folder but after that and imported it as "Existing Gradle project" and it works. – CptDayDreamer Oct 31 '19 at 10:48
  • 1
    @CptDayDreamer True: I have edited the answer to add the `git restore` step, which would have restored the files you just added. – VonC Oct 31 '19 at 13:49