Host your own Code Repository (GIT)

Code Repositories

As all developers know, Murphys Laws is a powerful guide to keep in mind and help us (in one way or the other) to prevent big catastrophes. Maybe I’m exaggerating a bit, but you all get the point.

Until a few years back i didn’t use code repositories, more exactly control version system. I didn’t use it, didn’t need it and most of all I didn’t knew of their existence (Ye, shame on me). But when I went to college, I felt the need to backup all my work, after all the teachers didn’t care about the “I hard drive died” or “my computer went kaboom” excuses.

So i started my investigation about code repositories. I found out about CVS, but it was starting to be discontinued and I couldn’t find any free CVS repositories. Next I found SVN, seems promessing, Google has SVN repositories free and with some configuration you can turn them to private, add users, etc. Felt great and I used them for a few years. Although it has many vantages, there was not much system explorer integration and I used them both in Linux and Windows, or even great integration with Eclipse and Netbeans. Maybe is was a big idiot, but times to times i had some trouble and didn’t had my code at the latest state. I assume, my low experience and lack of method provided my biggest headaches.

After a few years, it came to my attention the existence of another flavour: the GIT. One distributed VCS with great functionalities and make me wonder how is the feeling of working with it. Well is great, i don’t want anything else (by now :P).[Some comparison  about them both:] By searching for git hosting, i found out about github (which is free and the repositories are public) and bitbucket (also free and the repositories are both public and private). There are many others out there:

This is great but … … … they are hosted in the Internet. In some contexts it is not desired that we have the repositories in Internet, but we need, no, we want one repository to control version of our work but, unfortunately, there is no repository “in house”. In this “tutorial” ( explains how to setup a git server, but in my humble opinion is a bit complex for a simple, one project repository, so I searched a little more.

I looked at GIT documentation (yes, it’s true. Sometimes I read the manual :P) and noticed about the “git init –bare” command, that provide a local repository, which is great. So if you have a shared (and mapped) network drive, an external drive you can initiate a repository and them you can work as usual, by cloning, commiting and push actions.

Nice, right?

I also found this article by Jimmy Theis ( which explains how to use your dropbox account to backup your repositories. Although I didn’t tried with others storage hosting, i believe that should work with Onedrive service also.
Some considerations, learned by the hard way:

  • While working, commit each functionality that you are working. One at the time. If something was buggy, it’s is easier to “undo” one commit rather then “undo” multiple functionalities in one commit.
  • Commit often, push once. Since you don’t need to be connected to “commit”, you can “commit” as often you need to accomplish your goal. At the end, just “push”.
  • Although you don’t need any application beside GIT to the work, sometime is a pain doing the work in command line. I suggest the usage of a GIT client. I use Atlassian SourceTree (, it is great and work both in Windows and Mac. It helps you to keep track about your repositories and can sync with github and bitbucket.
  • If you like and want to use the command line, don’t forget to add files before committing. They are not added by default.
  • GitIgnore is your friend. Use it and abuse it. This functionality help you to keep out of track unneeded  files. Very helpful in Visual Studio projects.
  • Don’t forget, just don’t, to add to GitIgnore any file that you have containing usernames, passwords, connection strings, etc. One in the Web, you can’t control who sees it, an by a security measure you have to change all services credentials. A huge pain in the head. 😛

Just a few insights to those who are a bit distracted 🙂

Keep it tuned.