git server with eclipse project - eclipse

I have a computer running Ubuntu Server. On this computer I have a user named mattgit.
I have another computer running Windows 7. I develop Java applications in Eclipse on this computer.
On my server, I have run "git init --shared --bare" to create a central repository for an Eclipse project. I've done this once for each project in my Eclipse workspace, each in a separate folder.
I want each project in my Eclipse workspace on my Win7 machine to act as a/be a/whatever the terminology is git repository. I want to be able to then push these files back to the central repository on my server. How do I do this?
I've tried cloning the (initially empty) central repository to my Win7 machine to a folder in my Eclipse workspace and then creating a project in there, but Eclipse refuses to create it because it says the directory isn't empty.
I've also tried creating the project using Eclipse in my workspace, then cloning the repository into that folder, but apparently I'm not allowed to do that either.
I've tried using SmartGit and the Git binary and I'm just getting more and more confused.
EDIT: Please assume I know absolutely nothing about what I need to do. I need step-by-step instructions.

You will need three things:
a Git listener service able to listen to your git command (and you don't need gitolite at all here: it is an authorization layer).
See GitStack for Windows (there is a free version)
a git Eclipse plugin including in your Eclipse in order to not switch context when you want to do a Git operation: make sure EGit is installed in your Eclipse.
some instructions importing your existing Eclipse project into a local git repo and to declare your Windows GitStack repo as a remote, in order to push to it.
Create a local repo and import your Eclipse project into it.
Add your remote and push to it.
The instructions of Egit on GitHub are quite complete.
The Vogella's tutorial on Egit is also nicely done.

The simpler way to do that is to create your new project within Eclipse, then right click on the project and go to Team > Share menu.
This interface will guide you to create a new local repository containing your new Eclipse project.
Once your project is managed on a local git repository, Eclipse will give you other context menu entries to manipulate the project on Git. So you will be able to push your commits on your remote repository (the one you created on your server).

Related

Local GIT server and Eclipse

I've worked with SVN all my life and, right now, I'm trying to learn a little about GIT. In order to do so, I have created a local private GIT server in a RaspBerry and connected it to my Eclipse.
Until now, I have created a folder in the raspberry (/home/pi/raspberry-repo.git/ ) and formatted it as a GIT repository ( git init --bare ) creating the following directory structure:
I have also successfully connected Eclipse via SSH to such repository but I have some question that may be conceptual in nature:
I already have 2 local projects in Eclipse and I have executed the Team>Share Project in them, in order to add them to the LOCAL repository in my PC. After that, I have made some commits in both projects to such local repository and pushed the changes to the remote repository in the raspberry. My doubt appears when I look the GIT perspective in Eclipse.
In SVN the usual structure is:
but in GIT the structure seems to be this:
So, AFAIK in order to download a project from a remote repository I must File>Import>Projects from GIT, select the branch and the project in such branch.
Is all this correct?
Should I use just one project per repository? (Create a folder in the raspberry for each project )
Another question is why I'm unable to see any proper file from my projects when I browse throught the Raspberry filesystem (I just see a new folder inside of the Objects folder for each commit). The repository is not stored in plain text... Is that normal or I'm making some mistake when configuring the repository folder in the raspberry?
Hope you have patience with this doubts! By the way, any GOOD tutorial is welcome (the ones I have found aren't very good)

How to use Egit with ssh

I have always used gitHub as my repository but now I decided to store my source code into my local server (Ubuntu 14.04).
I use Eclipse as IDE and to make it working with git I installed Egit plugin.
My objective is to have a centralised repository in my local server at 10.3.16.1 and use my desktop pc and my macbook to push and fetch data from it.
My existing maven spring web based application sits at the moment on my laptop (eclipse)
I created a local git repo and then I added and committed all files. (so far so good)
Afterwards, I created a new remote as follow
I then pushed the master branch to the server but despite it says that the process has been successful I cannot clone the entire source code from my pc but only metadata like commits etc but not source files
Any thoughts on this?
Thanks
I managed to solve this problem on my own.
Apparently Git does not store source files in the centralised repository but only objects.
In order to import all source files I did the following on my PC
In eclipse File-> Import-> Git-> Project from Git
Then I selected Clone URI
I filled the location of the repository as follow
Eclipse retrieved successfully the master branch
Set the local destination of the new repository on my pc
And then I imported all sources accordingly as follow
Then I added the project to my working set
Hope this can be of help

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.

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.

Using Git With Eclipse Remote Systems Explorer

I am doing web development using CFEclipse with Classic Eclipse (Indigo) on a Windows Server.
I am using Remote Systems Explorer to access a Linux box via sftp.
The Linux box has Git installed. There is one branch in the development folder.
I have installed EGit in Eclipse, but there are no provisions for working with a remote system.
Because I cannot develop locally, how should I checkout files, edit and review changes in a browser, and ultimately commit properly? There is no local repository and checking out files through ssh (putty) while editing them in Eclipse does not show my changes when browsed.
If you can access to the remote location through ssh why you don't just simply clone the repository in local and then pull and push the changes ?
I think that cloning the the repository is the best bet in your situation, you have only to install msysgit on your windows machine ...
You can use remote project to achieve what you need. Unfortunately, git operations need to be done on the remote server. But, you can change the files and the files will be changed remotely on fly. To create the remote project you have to right click on the remote folder you want to create the remote project. The context menu you will find "Create Remote Project".
What Eclipse will do is make the modification thru RSE. This means, eclipse will deal with save files remotely.