Friday, March 23, 2012

Experiences with local Git and Eclipse

Some weeks ago I wanted to learn a little bit about Git because it is quite a buzzword. I already knew how to work with SVN and CVS, so I thought that it couldn't be very different.
I won't list any differences between those here. You can find out by yourself (and you are encouraged to do so ;) ).
What was really useful for me, was, that it is pretty easy to put a local folder under Git control. Just installing Git, adding it to the PATH-variable and that's all the preparation you need.
After that, just switch into a directory you like and type:
git init
Now your folder is under version control. (if you type into your shell ls -la you'll see the new .git folder)
If you put some files into that directory and add them with  
git add
and commit them with
git commit
Now you can keep track of your changes.
Of course, if your hard disk gets broken Git won't have any use for you. But one possibility would be to add a folder to Git (as described before) on an external hard disk or an usb-drive and then, on your hard disk, call
git clone "path to the external drive"
Now you are able to store your changes there and, depending on how you treat your hardware ;) , keep them quite safely.

Another nice advantage is, that you can put your existing Eclipse projects under version control and then use EGit. You only have to remove those projects from Eclipse, call git init on them and add the repository to Eclipse (under Git repository view). Now you can import them from the repository view.
It'll look like this:

EGit showing some repositories, including the local one

Last week I accidentally deleted a src-folder from one of my projects because I didn't read the Eclipse dialog, if I was sure about doing that. What a luck that folder was under my local version control. I was able to restore everything (of course except for my last changes).

It gotta thank the people of because that website is a really good overview for the different commands. I'll try to shorten those commands a little bit, so that they fit one piece of paper and put that file up, so everybody can print it, as kind of short reference. But before I do that, I will ask the gitref people because I used their website.


Post a Comment


Copyright @ 2013 Wrong tracks of a developer.

Designed by Templateiy