Is it possible to use EGit without having to Share Project? - egit

For now, I only have a local .git subdirectory under my Eclipse workspace and I don't feel the need to push it to shared repository.
I would like to also use EGit, but its user guide provides only a Share Project way to do that.
Can I re-use my local .git without having to push/publish/share it?

"Share project" in this context doesn't mean, that you have to share your project to a remote repository. It only means, that this Eclipse project is connected to a (local) Git repository. And yes, in this case you have to share your project, so that Eclipse detects the Git repository.
I think, "Share project" originates from a time, where there were only centralized VCS, and in that case, your project really was shared with a central server. Now with decentralized VCS, another term may be better suited.

Related

Is it possible to share a project without commiting?

I'd like to use "Share Project..." in Eclipse without actually commiting to SVN. Unfortunately, I am not able to find an option for doing this.
Instead, I want the relevant files only be added to SVN.
My goal is, that SVN should track all the files I move into the project using the package explorer.
Share Project needs to accomplish two things:
It sets up some internal linkage in Eclipse that connects your project with the SVN Team Provider so that SVN menu actions are exposed and so that activities you perform are routed to the SVN provider to "handle".
It has to establish your project as SVN "working copy" so that the SVN API that needs to be called on behalf of your actions can do what it needs to do.
So the key here is that if you already have a SVN working copy then Share Project will recognize this and be able to do option 1 without needing to do anything else. But otherwise, it has to establish a working copy which requires it to do svn checkout from your repository. If it has to create the working copy then it makes the assumption it needs to create the project in the repos and then check that out on top of your local project. So the one commit it will do is a svn mkdir for a folder in the repos.
If you do not want to do that, then do something to establish a working copy locally before you get started, such as checking out some existing location in your repository. As others have noted, you may want to be using branches and switch if you are refactoring something that already exists.
When you commit data to the SVN repository, you publish this new data or make changes to existing data (i.e. you make your changes available to others). Therefore, you need to commit your changes if you want others to see it in your SVN repository and collaborate.
As far as I recall, "Share Project" command in Eclipse is designed to import your non-versioned project to the SVN repository (i.e. make a first-time import) -- it converts your local data into a working copy and commits it.
I do not understand what exactly you mean by "share but not commit" (you may want to elaborate). However, you can always select which files to add and commit or import into the repository, but I guess that you will need to use standalone SVN client outside of Eclipse.

Eclipse - sharing project directory with multiple users

We are trying to set up Eclipse so that two users can share the same project directory on our server. Is this possible? Every time we try, it creates a new folder and project.
Thanks!
Chris
No, this isn't possible. Eclipse only supports a single user accessing a workspace (not just a project) at a time.
Use a source control system such as Git or SVN to share code. Eclipse supports many such systems and has extensive sharing support in the 'Team' menus.
The best way to do this would be to use source control.
Sharing the actual workspace or the files with different eclipse instance is a recipe for trouble.
An easy way to do this would be to install git on your machine and also on his machine. Eclipse actually already has git in it ready to go so you probably dont need to install anything.
The one with the files locally will create a repo locally on his computer and commit the files to it.
Next you want to init a new empty repository on a shared folder and push your local chances to this as you would to github for example.
Your partner can then git clone from this repository to his machine and work locally.
Each of you will develop on your own copy and commit your changes locally. You will share your changes by pushing your commits in that central repo and pulling from it to get changes from your partner.
You could also just open an account on GitHub, GitLab or BitBucket (there are many others too) and use that instead of a shared folder. big advantage with these services is that they will be available from anywhere.

Egit Eclipse best practises (play framework 2,.0) project

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:
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.
How can I prevent to generate a new project every time someone clones the repository?
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
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.

What version control system should I use?

I'm working by myself on a project. I'd like an easy to use, free, version control system that integrates with IntelliJ IDEA nicely. I'd prefer if the whole repository was isolated to a single file, or folder, so that I could back it up on a USB stick easily and transfer it to another computer.
Take a look at Git. The whole repository is in the .git directory under your project root (by default) and I believe IntelliJ IDEA just integrated Git functionality recently.
Assuming you are going with the default (having the .git directory in the project root), then you can just copy your project to a USB stick and you have your project and repository to go.
Amongst the various IntelliJ IDEA VCS support, the one for git is fine and easy to use.
Plus, with git bundle, you can export your repo to one file, very easy to copy around (on a backup storage for instance).
See the SO question "Backup a Local Git Repository"

Working with ProjectLocker

I have an account in ProjectLocker and a project in MyEclipse.
How to upload this in ProjectLocker?
I'll make the assumption that you want to use Subversion, as I don't know what support MyEclipse has for Git.
ProjectLocker's Subversion is 100% standard, so adding a project is the same as it would be for any other Subversion repository. The URL for projects of which you are a member is presented on the home page. You should be able to right-click on your project, select Team. . . Share Project, and then add the ProjectLocker repository with the URL, name, and password you were issued. This connects your local project with the ProjectLocker repository, and then you can add and update files as you see fit.
If you already have files uploaded, you can use the SVN Repository Exploring perspective to find the project and directory and check out a new project.
ProjectLocker offers subversion and git repositories. First you obviously have to decide for one or another version control system and add the required plugins to eclipse (for subversion or for git unless MyEclipse already has the connectors).
Then it's pretty straightforward - add your repository (ProjectLocker should provide you the correct URL) and share the project.