Recommended Eclipse EGit workflow - eclipse

Group,
We use Borland Starteam as our source control system. I develop Java code and use Eclipse as my IDE. I recently started using EGit as my personal source control system and came up with the following workflow to streamline my dev work, which consists of checking out code, adding features, fixing bugs, testing, merging with the parent source in Star team (huge effort if lots of people have made changes in the meanwhile), build, test, and install. I want to use EGit to simplify the compile, merge and test process, while developing and also just before code install after big merges are made. This is what I have come up with.
Create file system folders - 'Master' and 'Work'
Check out fresh source folder structure from Starteam into 'Work'.
Create Eclipse workspace called 'Work' and import Eclipse projects from 'Work' folder add those projects to an EGit repository.
Add features/fix bugs while in 'Work' workspace. Test, etc. Create a patch when ready to install. Now its time to make the big merge, rebuild, test again.
Check out fresh source from Starteam on the day of the install into 'Master' folder in the file system.
Create Eclipse workspace 'Master' from source in 'Master' folder, import Eclipse projects and add those to a newly created EGit repository.
Import patch into 'Master' workspace, perform merge. Fix compile errors, test, etc.
Install.
Is this workflow efficient? Are there more advanced features in EGit that would simply this any further?
Thanks for any guidance.
Ranjit

Unless I'm understanding this wrong, it looks like you are using eclipse workspaces in place of the existing git branch functionality. Egit, if I'm correct, can manage branches all on its own so you don't need to run back and forth switching workspaces. You can create then merge branches and do all the other fun stuff within a single project.
The workflow from here is all git. A good article on maintaining a sane workflow can be found here: http://sandofsky.com/blog/git-workflow.html

Related

GitHub + Eclipse Workflows

I am sure this is a RTFM thing, but after a few days of research I still cannot determine the correct (or best) workflow for this.
I have an Eclipse Workspace with a number of Java Projects in it and a number of C++/Arduino projects.
I want to start using GitHub as an online repository (easily reachable from outside my private LAN dev environment) for my projects
I was thinking I would like a separate C++/Arduino and Java GitHub repos. More could come for Python, PowerShell, etc. (But I will happily entertain other recommendations for repo structures).
Outside of the actual mechanics of using Egit, I cannot figure out the most appropriate workflow/folder structure for accomplishing this. Should I create local Git repos and push to GitHub as a remote? Should I use GitHub's web interface to import the entire Eclipse Workspace? Should I work directly with the Eclipse Workspace or have separate Git folders?
I guess the crux of my problem is that after reading a few related posts on this site I get conflicting advice about creating a local repo from the Eclipse workspace vs. a separate local repo. I think I need to understand this distinction first before I ultimately determine the best overall workflow.
I apologize for the broad nature of this question, but I hope that the community can help me narrow the workflow process design (or the question itself).
Two things up front:
Never put your entire workspace in source control; projects: yes, workspace: no. The .metadata folder contains data specific to that location and your machine, and that's ignoring any potential security risks with making it public.
eGit works with your git clones' own metadata, so if you're more comfortable doing certain things from the command line, go for it. I know I am, but I still appreciate the UI and decorations that eGit provides. Just make sure any automatic refresh/update preferences on the Workspace or Git preference pages are turned on.
You probably want the repository to contain multiple projects, rather than having a separate repository for each one. That way histories and changes that belong together are together. Nest the layout however you like, but remember that you're not constrained to a single repository for everything, either.
I don't know that there's a best practice for this, especially with projects that already exist, but projects should themselves be relocatable. My recommendation, after backing it all up:
Make the Github projects, clone their repos locally. I do it this way, from the command line, to save me any headaches with the history, remotes, and refs. I don't think you can modify the repository metadata in this method, though.
Move the workspace projects into the local clone. You can delete them from the workspace (be sure not to delete the underlying files), physically move the directories while outside of Eclipse, and then import them as projects back in from the Git Repositories View--unless they're Maven projects, in which case it's better to use M2E's import wizard.
Stage, commit, and push the projects up to the remote origin. For Java projects, don't forget to set the JRE System Library in the Java Build Path to use an Execution Environment. It's a simple bit of indirection that makes them more portable across machines.

How to structure two eclipse workspaces and local and remote git repos

I have been using Eclipse IDE with egit and pdt for a couple of years. I have a local git repo outside my workspace and a remote private repo, largely for bckup - I am the only active developer. In addition to my projects (several sub-projects) I have imported a Joomla installation so that I can debug my projects in their working environment. So far so good.
Recently, I needed to start work on a big upgrade. So I created a new workspace and a new local git repo cloned from the remote repo. I imported a different Joomla installation and created a separate branch for the new code.
I am using one workspace to push to the remote master and the other workspace to push to the remote branch. I can 'see' both branches in both workspaces and I get myself confused because they are not usually in sync. And I get very confused when it comes to merging something from the master into the side branch. So far I have muddled along but I can't help feeling this is wrong and bound to lead to disaster.
It would be fair to say I don't know nearly enough about Eclipse or Git to figure out how I should have set this project up in the first place. And I don't know the exact steps I followed to set up the structure I have right now.
Can someone offer advice on a practical repo and workspace structure for working on branches that require different testing environments?

How to create Eclipse project with EGit clone

After spending a decade with SVN I've finally taken the plunge with Git. I have set up Git, Gitolite and GitLab on a server and have successfully added code to my local repository, committed, cloned repositories and pushed code back to repositories. So far, so good. Now enters EGit...
I have cloned a repository using the Git Repository Exploring view using the following syntax for the path:
ssh://dexter:vaultanalyser.git
(In GitLab, repositories are referred to as projects, so I assume that I am supposed to have one repository per Eclipse project? Rather than a SVN-style single parent repository that contains multiple projects?)
This imports the repository into:
/Users/mattpainter/git/vaultanalyser
I was expecting this step to automatically create an Eclipse project for me with all the source, but this isn't so. I tried fudging the target directory so it's in my workspace, but this isn't working either.
How do I get the cloned source available within Eclipse? This site implies that if you create a project with the same name as the repository, it all magically works, but this isn't the case (yes, I know the article is about Github, not GitLab, but I figured the two were close enough for the task at hand).
I've then tried creating a project in Eclipse and sharing it - but then the whole project appears as a sub-folder in the repository. If repositories are indeed analogous to projects, this isn't really what I want.
I've looked through other StackOverflow topics that look related, but I fear I'm still missing a key piece of understanding with how this is supposed to work and it's all looking remarkably convoluted thus far.
Help?
In GitLab, repositories are referred to as projects, so I assume that I am supposed to have one repository per Eclipse project?
Yes, but a GitLab "project" isn't necessarily an Eclipse one.
It doesn't have to follow an SVN structure, as illustrated in "Eclipse reference directory outside eclipse project directory but within repository".
All you need to do is to create an Eclipse project, specifying the source directory being not in the default path (Eclipse workspace), but wherever you cloned your repo (as described in "Getting started with Eclipse + EGit - confused").
That way, the eclipse project you just declared (and referenced in the Eclipse workspace) has its files (.project and .classpath) at the root of the Git repo.
And Egit can then manage that project just fine.
Or you can import it directly with Egit: "Eclipse + EGit: clone project into workspace".
As the OP nullpainter reports below:
The original issue was compounded by invalid permissions in the .git/objects folder on the server.
Running a chmod git:git -R * on the folder solved the issue
He details the right setup below.
To expand on #VonC's answer, the steps to get EGit and Eclipse to play nicely is:
Select 'Clone a Git repository' from EGit, accepting all defaults. This will create a folder in a git parent folder, somewhere outside your workspace.
Create a new Eclipse project. I'm using Java, but I assume there are similar steps for other languages. On the first dialog, untick 'Use default location' and instead select the repository folder created in step 1. Accept all defaults.
Select Team > Share Project... from your new project. Select Git, and tick the 'Use or create repository in parent folder of project'.
Now you can push your code and Eclipse dot files to your git repository from within Eclipse.
(My original issue was compounded by invalid permissions in the .git/objects folder on the server - running a chmod git:git -R * on the folder solved the issues)
I check it out with the command line - then build my projects on top of that. In fact, I end up doing most operations with command line git. EGit is useful for viewing the diffs but I find command line has more power and control. Git is mostly about giving devs lots of power and control.

Automating Eclipse project configuration

I keep my .project and .classpath files in my source repository. I maintain separate eclipse workspaces for each branch off my trunk. I've found the best way to do this is to recursively copy my trunk workspace (cp -r dev/ branch-foo/). This works great. There are a few other details that facilitate sharing templates and key mappings, but that's not important here. The issue with this solution is that I end up with a workspace that, to no surprise, contains all the trunk projects. I then have to remove all these projects from the workspace manually and then import all the projects in the branch. Not a huge deal, but I'm wondering if something better can be done to automate this process.
I don't see any files that get written to as I add/remove project files in my workspace so I'm assuming eclipse manages these relationships in some internal DB or something. Additionally, I looked into any command-line support eclipse offers for doing this, but don't see anything.
Any thoughts would be much appreciated.
One P.S. - I do see some binary files located in ~/workspace/branch/.metadata/.plugins/org.eclipse.core.resources/.projects/project_name/

Version control on an external project

I am working on an enormous project ("the project") which is open-source, and I am changing the project but don't have a permission to commit. I'm looking for strategies for maintaining my own branch of the project. Some issues I am contemplating:
How to put my own work in a version control system, given that I'm altering the project's source code, adding new files and so on.
How to keep in sync with the project without having to manually merge my own changes over and over again.
I've never been in this situation - I've always maintained my complete project in some version control system. My plan right now is something like that:
Creating a directory tree in my SVN, similar to the one in the project.
Keeping all the changed files (and only them) in my svn.
Every time I decide to sync with the new baseline of the project, I'll do a checkout, merge my svn tree into the new version, test, then commit my changes to my svn and distribute them along with the latest project baseline.
The problems here are ENDLESS. Way too many manual steps, more and more work over time, and so on. The correct way to go would be, of course, to be a part of the original project, but this seems to be quite irrelevant right now for various reasons and is out of the question.
Ideas?
I'd use git or mercurial for this; simply import the project into git or mercurial, and merge the upstream changes into a branch in your project for easy merging into your trunk.
If the upstream project has a repository of their own, the import is even easier. Both git and mercurial have support for directly importing other version control systems. I did this recently to adapt an existing project that lives in SVN: https://github.com/mjpieters/rod.recipe.rabbitmq
Note that that project has an 'upstream' branch. That particular project has now accepted my proposed changes after reviewing the changes in github.com.
There are a few questions here on SO on the subject:
Fork and synchronize Google Code Subversion repository into GitHub
Tracking upstream svn changes with git-svn and github?
Best way to fork SVN project with Git
It should be trivial to create a similar setup with mercurial.
You can use git to maintain your source control on your local system. In fact Git can be used to maintain just about any directory under version control. There is no need to sync to anything, git maintains all changes locally.
If you need to commit to SVN check out the documentation http://git-scm.com/docs/git-svn