martes, 3 de diciembre de 2013

Working with versions: Git




What's Git? Wikipedia says: In software development, Git /ɡɪt/ is a distributed revision control and source code management (SCM) system with an emphasis on speed. Git was initially designed and developed by Linus Torvalds for Linux kernel development in 2005. Based on a recent survey of Eclipse IDE users, Git is reported to have 30% adoption as of 2013.

What does that mean? Well, the most basic example of the use of git is a web/app/somethingelse which is developed during days/weeks/months. During that time your code is evolving and changing, adding new features and solving bugs. But sometimes you make a mistake and modify parts of the code that you shouldn't modify and the worst part is that you think that everything is OK. Weeks later you realize that something in your code doesn't work and the origin is a code your erased/rewrote weeks ago. If you are using Git you don't have to worry, only search for the old code and add it to the new one, easy!

The other situation which Git is very useful is when you're working with a team of developers. Everyone is working with his own copy of the code, but when someone has finished some feature of new classes, everyone will be able to download it to his own copy almost seamless, only worrying about the files both has modified.

In the first case we only need a local repository, once initialized Git will track all of the modifications of your code. When you feel that want to make a 'snapshot' of your code, you can commit the changes and add a message. Then using for example SourceTree you will be able to see all your commits and dive through them.

In the second case you'll need a shared repository, the most famous is GithHub. GitHub allows you to have any number of public repositories (everyone can see your code) and if you pay you can have private repositories, which is useful for companies. You can work with your own code as long as your wants before adding the others code to your own, but it's a bad practice because the more you waits the more code you'll have to add which can lead to divergences and bugs.

Last but not least is the ability of Git to work with different branch of code. Typically there are three branches: production, preproduction and development. The first is the application in his most stable form, the one that is in the store or you use to show the development to the client. The second is a stable version in testing mode, in theory there isn't bugs here. And the third is where the new code is tested. In addition every developer has his own branch where he is saving his own code and when he is sure that it's ok he will merge it with development, where at the same time when is tested will be merged to preproduction that will be merged with production.

As you can see, Git is an extremely useful tool that maybe is a little hard to use, but it's worth it!

Some useful links:
- Git homepage.
- SourceTree, a very useful Git client.
- A big tutorial about Git.

No hay comentarios:

Publicar un comentario