Local GIT server and Eclipse - 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)

Related

Eclipse Workspace on a network folder (UNC path)

I am working on a project which has GitLab repository and the local repository is on a network folder so I wanted to create an Eclipse Workspace on that folder as one can share the project with the other team members but when I tried to build the project I got an error message which says that eclipse workspace can't be a UNC path, so my question is, is there any work-around way I can do this, for example is there any way I can let the OS (Windows 10) link a local folder to the one on the network so that every member would do the same and work on his own local folder and it will be automatically edited in the network folder?
Thanks
No, this is not possible since everyone needs their own cloned Git repository to work with.
For instance, switching the branch or staging files are per repository and would therefore affect everyone. When you clone a Git repository without the bare option, there will be a so-called working tree which is the location where the currently checked-out files are and this folder is not copied but mapped into your workspace. Everyone would not have a copy of those files but working with the same files.
Besides the editing conflicts you would have, another disadvantage of having a Git repository on a network drive is that it would be slower. Therefore one would not want to have this even if it were possible to have Eclipse projects on a network drive.
But since in most cases a Git repository including the working tree takes less disk space than in SVN the working copy of the same, it should not be a problem if everyone has a locally cloned Git repository.

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

How do I store projects that share a common shared driver on Git

I'd like to create Git repositories for some of my existing STM32 embedded C projects that I'm developing with Eclipse.
Currently I have two separate projects in their own folders, and a common folder containing ST's official STM32 Cube peripheral drivers (.c and .h) files that both projects use.
The driver folder shouldn't change (except when new versions are released) but the project files will be edited as I develop them.
How should I place them on Git? Should I:
Have three repos (one for each project and another for the drivers)?
Have two repos and change my project structure to place the drivers with both projects?
Something else?
The first option seems OK, but if I don't clone both the project and driver repos, and do them to specific locations, I can't see how I would configure Eclipse properly.
The second seems more hassle free but redundant (it won't be as easy to update all projects to use new drivers as they are released, and it will use more server space).
EDIT: Just to clarify, I'm not using the STM32CubeMX software. I'm simply using the STM32CubeF4 peripheral drivers, which are basically just embedded C .c/.h source/header files for the chip's internal peripherals (and possibly a few .lib library files for DSP calculations). See the "download" button at the bottom of this page for the .zip archive (current version is 1.4.0): http://www.st.com/web/en/catalog/tools/PF259243
If you use a common driver in several other repos, it looks like a job for git submodules.
You have three separate repos, for example on your server, and both projects include the driver code as a submodule. What is stored in each project repo is:
an URL to the driver repo (on your server)
which commit of the driver repo is to be used
the path where to put the driver clone, relative to the project repo
After cloning a project repo, you run git submodule update --init, and the repo at URL is cloned into the relative path, and its commit is checked out.
git submodule add --name <driver> /server/src/driver.git driver
(/server/src/driver.git is URL, driver is path. <driver> is just an optional reference to ease future work with submodules. Don't use it if it is the same as path)
git submodules feel a bit cumbersome at first. For example, cloning or checking out commits in the parent (project) repo does not make the submodules working files up to date. You have to manually git submodule update for that.
You will end up with two clones of your driver, one in each project's working files structure. But this is not really redundant, as they are clones of a common driver repo on your server.
For every update of your driver, you push the driver changes to your server. To update to the latest driver version in another project, you go to that project's submodule, do the usual git push (you might be in detached state, in which case you need to checkout master first). The update will show up in the project's (not the submodule's) git status, which will tell you "New commits" in the driver submodule. What has changed is which SHA1 is checked out in your submodule; commit the changes in the project will only update which submodule commit is to be checked out.

Confusing Eclipse and Github interactions

We are trying to use Eclipse and github on a project, and it is proving to be a real burden because we do not understand how it works. It is difficult to formulate a single question, but let's start with one case:
We have a project in Eclipse that is on github. Several developers are sharing the archive. We learn that we want to create a Java EE project rather than a Java project. We do not want to change the name of the project. How can this be done?
Further, not knowing this, we tried to change the name from ProjNamet to ProjName2.
When creating a project on git, Eclipse creates it in a local directory:
c:/Users/username/git
In order to push that project out to github, we executed:
git remote add origin github.com/author/projname
git push origin master
As far as we can see, the project appears to be successfully pushed out to github.
In addition to source code, there is:
.project
.gitignore (which just ignores the build directory)
.classpath
.settings
But when I right click on the repository and try to import projects from it to my computer, Eclipse failed
deleting the directory, and clicking on File->import.. and importing from the repository works.
I do not see what the difference is between the one that worked and the one that did not.
Try this:
git remote add origin github.com/author/projname
git push origin master

git server with eclipse project

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).