How to initialize git for a new eclipse java project (neon)

I installed a fresh copy of eclipse Neon and created a new gradle java project in a new and shiny workspace. What's the best practice for adding git to a party?

I read that initializing git in the project directory is really a bad idea .

What's a particularly good idea ?!

Thank!

+3


source to share


1 answer


It's a good idea to git init a parent project folder other than the main workspace folder .

This is exactly what happens if you allow Egit git to execute the project (right click on the project -> Team -> Share Project -> git -> ...) and select an external folder as a repository, say C: \ Users \ john \ my- git -repository.

You will have two folders:

  • c:\users\john\my-git-repository

    containing a folder \.git

    and\<my-project>

  • c:\users\john\<eclipse-workspace>

    an eclipse workspace folder that will NOT contain your project folder (remember that an eclipse workspace is just a logical container for projects, they don't need to physically there).

Another option is to create a folder inside the workspace, create a project as a subfolder in that folder, and then git init that folder. Thus:



  • c:\users\john\<eclipse-workspace>\shared-projects\<my-project>

You will create a repository in a folder \shared-projects

(either on the command line using git init or from an Eclipse application using a wizard) that will contain the folder \.git

, folder, \<my-project>

and any other project you want to share.
Remember why Eclipse suggests keeping repositories off-workspace ( https://wiki.eclipse.org/EGit/User_Guide#Creating_Repositories ):

It's a good idea to keep your repository outside of the Eclipse workspace.

There are several reasons for this: The

new repository will treat the entire Eclipse workspace folder structure as (potential) content. This can lead to performance issues like calculating changes before committing (like scanning the entire .metadata folder)

If your git repository is in a folder \shared-projects

, the repository will NOT treat the complete Eclipse workspace folder structure as (potential) content and will NOT scan the .metadata folder as it is outside the repo. The only content in the repo will be your collaborative project!

0


source







All Articles