Simple Private Git repo/server

 

The past days have been hectic. A lot was happening on my personal as well as on my professional side and by a lot, i mean, enough material to keep 3 or 4 blogs posts rolling. So instead of being stuck on an infinite cycle of deciding where to begin, I am taking the easy way by writing something that has been on my mind for a while. 

Every developer, devops, sysadmin, security analyst and even science and engineering students are aware of the word GIT. For any of you who have the preconceived notion that git is just version control the the answer is , like the folks say here , "Jaein". Side note: Its a combination of Ja + Nein. Git is version control and yet it is more. Taking github as an example, at first it was just programmers/developers working and sharing on some common grounds and the as years progressed, people started sharing .config files . Infact, i remembered one of my first few commits were some of my Xmonad config and .Xinitrc config files. Then it became a point where docker images were plentiful which was followed by the academia. In the begining,  it was just compsci students adding their group study/projects etc. And there are whole assignment questions, latex templates for publications, beamer presentations, lecture notes. The best one of them all came from a very good friend of mine. I was discussing with this person about where to deploy a simple static website template,(more about the web template in another post), and I got a calm reply, "have you tried hosting it in github or gitlabs?".

Wait!!!! what? github is a webhosting company now? Then i did  bit of digging and found that eventhough it is viable to host and a few people have managed it. Which brings me to the original point that i started with, git is a version control but things have grown so much around git that it has become more than just a simple version control. Having mentioned it, now lets move on to the second part of what i wanted to post.

Most of us are lucky enough to work only with github or gitlabs or bitbucket. (Well, whatever strikes your fancy) Apart from their business model, I personally do not find much difference between those 3. But, like the rule of exception states, occasionally, one might face a situation where you could not can rely on any of those 3. To add agony,  developing a full inhouse infrastructure with private git servers for repos might be like using jackhammer to squat a fly. This is especially the case if the project were of a sensitive nature , handling regulated data and with short term objectives to fullfil. In such a situation a simple private git server can be set up real fast.

The exact steps involved are infact fairly simple.

Step 1: Install git in the server which you have decided to use as a git server.  

Step 2: make a directory with a .git, for example, $ mkdir topsecretproject.git

Step 3: cd to the directory and  $ cd topsecretproject.git && git init --bare

Step 4: Finally, update the server info , $ git update-server-info

well , now all that is required is to set your credentials (keys if your are using keys, which you should be using anyway) for the new git server, make the local directory, cd to the directory, init a git, add some files , do commit, add the remote git server with credentials as repo and finally a git push.

Going back to step 2 and 3, incase anyone is wondering what is the significance of a directory with a .git ending, here is the full explanation. Git init command is used to create a new git repository. But what it actually does is to create a .git subdirectory inside a project root and the keyword --bare is used to initialise an empty repository. One can simple combine Step 2 and step 3 with a simple command as, git init --bare topsecretproject . Since git commands are usually not available untill a directory is initialised, i personally prefer to use linux commands and keep git commands for a later stage. So which method you adopt is just a matter of convenience and personal preference.

Happy commiting then.

 

Add new comment

The content of this field is kept private and will not be shown publicly.

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.