-1

Im very new to git ingeneral, egit and github.

The problem:

Lets say I have a project for eclipse in c:/username/workspace name "Test". So I versioned it and pushed it up to github. Now I can see all my Files in github under the directory "Test" in github. In example /src. The "Test" directory is not versioned. only the name of the repository is "Test". My next step was to delete my local files and fetch my project again(For testing). After that I had to import my project again (but I had to use the new project wizard) over the egit view. Unluckily also the wrong scala version was detected. (Was a play framework project). So I had a big exclamation mark on the project view.

My questions:

  1. What is the best practice to oush a project to github so everyone can participate? Everything under the project folder? Obviously some information got lost through the process.

  2. How can I prevent to generate a new project every time someone clones the repository?

  3. What about best practices for using git inside the workspace. Eclipse warned not to put the project inside the workspace.

Im coming from a subversion background :/. Maybe a general missunderstanding.

Thanks in advance

whereismydipp
  • 556
  • 1
  • 8
  • 23

1 Answers1

7

Switching from SVN to Git in an Eclipse environment can take some getting use to. (I'm still getting accustomed to it myself.) Keep in mind the difference between the role of the .git folder and the .svn folders for Git and SVN respectively. There is a .svn folder at every folder level in the working copy. There is no .svn folder in the traditional Eclipse workspace root. The "source controlled things" are subdirectories of the workspace, not the workspace itself. This is generally good because the workspace contains desktop specific settings that one generally doesn't want shared (much of it in the .metadata directory).

With Git, there is only one .git folder that contains everything. The first impulse is to do a

 git init

at the workspace level. This would make the subfolders (the Eclipse projects) eligible for source control. But wait, so is .metadata. Of course you can ignore it. But you may have to ignore lots of other folders (projects) that you do not want source controlled. Of course, the .gitignore should be included. But others will have different files to ignore.

It turns out that its easier to use Git with Eclipse if you place the .git folder and its sibling source controlled folders (Eclipse projects) someplace else besides the workspace root. Your view in Eclipse doesn't change. You still see all your projects, both the Git-controlled and the SVN controlled and ones not shared at all. But underneath in the filesystem, the Git-controlled folders will be somewhere else. This is what EGit prefers.

On my desktop, I have a workspaces directory for most of my Eclipse workspaces. Now that I use EGit, I also have an egit directory where I keep the local EGit repositories. The Eclipse workspaces that share using EGit reference a subdirectory of egit. It's from these local Git repositories that one pushes and pulls from GitHub.

Sorry for the length. I got a bit carried away.

pglezen
  • 961
  • 8
  • 18