Git-svn and Eclipse? - eclipse

Is there a plugin for Eclipse for git-svn? I'm looking for a way to handle the SVN repo with Git (for fast branch switching etc.)

It does not look like there is a Git plugin for Eclipse that supports git-svn yet.
EGit appears to be the most active and popular Git plugin for Eclipse at the moment and it does not support git-svn, but there isn't anything stopping you from using EGit with Eclipse and interacting with git-svn via command line (or via tortoise git for example).
Eclipse bug 315264 is the EGit bug for supporting git-svn, and it looks like something that the maintainers of EGit are willing implement, but they have other priorities atm. So make sure you vote for this bug if you want the feature.

EGit is the only Git plugin for Eclipse at the moment. It doesn't support git-svn. But there is a way to make EGit work with your Subversion repository and this approach works well with any other Git client.
SubGit is the server-side solution that enables Git access to your Subversion repositories as well as Subversion access to Git repositories. You may refer to SubGit documenation for more details, but in general they are quite straightforward:
$ subgit configure --layout auto $SVN_URL $GIT_REPO
# Adjust $GIT_REPO/subgit/config
# to specify your branches, tags and other settings
# Adjust $GIT_REPO/subgit/authors.txt
# to introduce svn author names to their git counterparts
# Adjust $GIT_REPO/subgit/passwd
# in case you have no SVN credentials cached on your machine
$ subgit install $GIT_REPO
$ ... translating ... a little git is gonna born right here ...
$ TRANSLATION SUCCESSFUL
After that:
You have Git repository at $GIT_REPO synchronized with SVN repository at $SVN_URL; this sync is reliably bi-directional, i.e. both SVN and Git repositories remain writable and SubGit takes care of changes from both sides.
SubGit has installed hooks into $GIT_REPO/hooks directory which are triggered on every git push to that repository.
SubGit polls SVN repository in order to fetch new revisions.
Please note that your teammates may use the same mirror for sending their changes to Subversion repository. In this case you should setup Git server, fortunately, SubGit supports virtually every Git server available at the moment:
Apache HTTP server with git-http-backend, GitLab, Gitosis, Gitolite: supported out of the box;
Atlassian Bitbucket Server: in this case you can use SVN Mirror add-on which is built on SubGit engine;
Gerrit: you'd need to install SubGit plugin for Gerrit in this case;
Disclaimer: I'm SubGit developer; SubGit is commercial software with free options for small teams, Open Source and Academic projects.

Although this question is 4 years old, I thought I would share my recently found workaround:
Open "External Tools Configurations" (right next to "Run
Configurations") and create a new "Program" configuration.
For the working directory, choose your project from the workspace.
Enter svn dcommit into the arguments textfield.
Duplicate the configuration and replace svn dcommit by svn rebase.
Now you can launch git svn dcommit and git svn rebase with two clicks.

Related

Will installing Egit interfere with existing Git installation?

I have been working with Git from the command-line for a few weeks. I am now on a project that uses Eclipse as the IDE and EGit for the Git plugin. I am worried that by installing EGit I'm going to destroy any Git configs in my existing projects (that I've been maintaining/coding directly from a terminal).
If EGit could interfere, how so (and how can I avoid this)? If not, why?
No, it doesnt interfere. EGit only works within Eclipse and is independent from a command line Git installation. Regarding the configuration EGit of course reads your existing gitconfig. But if you use a recent Git version on the command line, there shouldn't be any differences in the config.
In fact you can keep using Git on the command line for committing, pushing etc. It doesn't matter if the project is configured for EGit in Eclipse.

Is there a way to retrieve eclipse executed git commands?

I'm a regular git user, and I'm building some shortcuts in eclipse to activate some EGit functions.
I'm a bit wary of what is EGit doing (especially the synchronize workspace operations), and I was wondering if I could make EGit show what git commands it was using.
Do you know of an option to make it log to the console, or generally, how to find out which commands got executed?
EGit does not use the git executables. It reproduces, with the help of JGit, what the executables would do.
Git executables store the versioning state of a project in a number of files under the .git folder (branches, refs, commit objects, tags and so on).
EGit and JGit do the same.
For example:
A commit with git executables:
git commit -m "My commit message"
Would be executed in Java through EGit with CommitOperation.commit(), which uses JGit's CommitCommand.call(), which builds and inserts a commit object, which are representend through files.
There is no clear mapping between EGit's UI operations and their meaning as regular git commands, at least not to my knowledge.
One can go through (EGit, JGit, git)'s code and look for what is happening under the hood, though.
EDIT: a pgm package in JGit provides the inverse mapping: "Command-line interface Git commands implemented using JGit ("pgm" stands for program)"
EDIT: A not-merged Eclipse patch exists for logging what Egit does under the hood: https://git.eclipse.org/r/#/c/103342/
Please go to .git folder of your project. There will be a log folder like in my case (D:\Repo\GIT.git\logs)
all git command executed by eclipse are logged in respective branch file.
a sample of log is
0000000000000000000000000000000000000000 27f2e02544d389eb2412c1d467cc99f1786cd662 fanishshukla 1409137288 +0530 commit (initial): First Draft for Jboss
27f2e02544d389eb2412c1d467cc99f1786cd662 6d5634200cfdf6adf7c00ae70004326d2741e3a2 fanishshukla 1409557422 +0530 commit: fast response
6d5634200cfdf6adf7c00ae70004326d2741e3a2 32dbcfa55452b1a89861f422cfc7f90d26435d8c fanishshukla 1409557443 +0530 commit: fast response
What I found here:
There's a bug regarding this requirement:
Bug 349551 - Log EGit activities into a console
https://bugs.eclipse.org/bugs/show_bug.cgi?id=349551
How about git reflog to view command history of git

egit plugin for Eclipse

I have created a gitlab repository and followed the installation instruction by the letter and it was successful (i think... i can browse the repository online) and now I want to connect the egit plugin from eclipse to this remote repository.
I was using SVN for quite some time and now we need to switch to git and I am confused. egit only gives me the option to create a local repository but I'm a bit lost on how to push/fetch code to my online repository.
Any advice will be greatly appreciated :)
Thanks!
With Gitlab (working with ssh urls), that means you have to register your public and private ssh key in Egit first before being able to clone it.
See EGit ssh configuration
Then you can clone it.
And yes, you need to clone the full repo locally to work on it, that is the difference between a:
CVCS (Centralized Version Control System) like SVN
DVCS: Distributed Version Control System.
See "Sell me Distributed revision control" and "Describe your workflow of using version control (VCS or DVCS)" for more.
First you need to clone the remote repository using git clone <repository>, then you can import it to eclipse using egit
Or
You can use the clone functionality provided by EGit to clone the remote repo to local system

Git, SVN and Eclipse workflow

I am trying to adopt the following workflow:
git svn clone a svn repository through command line (egit doesn't support git-svn)
Open the project in eclipse with egit since I rather use egit to branch, merge, commit etc...
When i'm ready commit the changes back, I use use git svn dcommit to commit back to svn
I am having trouble with step number 2, don't understand how to import a git project, eclipse tells me i can't import it to use the same directory it's currently in because another project with the same name is already there. this is confusing.
Anyone knows how to do this ?
Also would like to hear other workflow examples that uses egit and git svn. I am aware that it is better to do it all through command line, however, I am trying to ease the move to git for fellow developers in my team, who are not used to command line interface etc...
I've worked briefly with the egit plugin (I actually recently stopped using it and just use msysgit as my Git guiclient and run it separately from Eclipse). I find Eclipse very busy as is and adding this plugin slows it down (for me at least).
What I did when setting up an already cloned project in Eclipse:
In Eclipse. File -> Import -> Existing Project into Workspace
Select root directory of project. Do NOT check copy projects into workspace. Click finish.
After project has been imported. Right click on project, go to Team -> Share Project
Select Git as a repo type, click next
Check use or create repo in parent folder of project. Since you already cloned the project it will be tracked with git. When you check this option it will show the project, the path, and the repo (.git).
Click finish and you will be all set.
I think you'd better use SubGit instead of git-svn.
SubGit works on a server side. It synchronizes all the modification between Subversion and Git repositories automatically on every incoming modification from either side.
From the client perspective SubGit enabled repository is a usual Git repository, so you may pull from and push to it. Please refer to SubGit documentation or SubGit vs. git-svn comparison for more details.

Working with several repositories at the same time with Subversive in Eclipse

I would like to use two svn repositories. One is to synchronize with my production environment and the other is to synchronize with another developer. Is it possible using Subversive in Eclipse?
EDIT: Sorry! I meant SVN, not CVS
I think what you means is "For one given project, I would like to be able to synchronise on one side with the official repo and at the same time, use the synchronisation and merging facilities to stay i sync with another CVS repository".
Best of my knowledge, this is not possible from the same project. Neither with CVS nor with subversion nor with any other SCM. This is a little bit because all SCM plugins are actually plugged into the Team Management plugins of eclipse and has actually a lot to do with the fact that the relation between a dev environment and a repository is quite exclusive.
What you have to do if you want to synchronize on an exceptional basis is :
Disconnect from one repo (say CVS) (team disconnect). Do not delete the .cvs folders.
Reconnect to a second repo (say SVN - either subversive or subclipse <= my preferred one)
Synch with SVN
disconnect from SVN
reconnect with CVS (team => share).
This is too risky to be done on a regular basis.
Therefore there are other strategies
Use a "shadow project" in your workspace synchronised through a regular synchronisation tool. The master project being connected to the CVS repo and the shadow to VN.
Use git + SVN. git as your local repo backed by SVN. The other developer can use a similar approach.
All in all there are no simple "out of the box" solution. All these solutions require a significant amount of commitment to work flawlessly. But SCM has always been like this, I guess.
Subversive adds Subversion
integration for Eclipse (subversion
is a version control system similar
to CVS). It does not handle CVS
repositories!!!
To use CVS repositories with eclipse
you should use the appropriate CVS
Plugin for eclipse.
You may even use both eclipse plugins (subversive and the cvs plugin). They will work with Eclipse like a charm (but keep in mind that subversive only handles subversion repositories).
Yes its possible to use Subversive in Eclipse. I am using Subversion and CVS both through Eclipse and Tortoise. Subversion is much faster and seems to handle binary files better. The one thing to get your head around is that revision numbering is totally different between subversion and cvs. May be this can help you.
Hope this helps.