Building and installing git 2.x on Windows

So Git 2.x has been out for a few months now and it came with some nice stuff, you can read more about it here

However if you are under windows, the git portage msysgit has yet to release a 2.X portage(as of this writing the latest version is 1.9.4)

If you want to install Git 2 on Windows you will need to build it from the source, and here is how it's done

1. Download the Git build environment

Head up to the Github page https://github.com/msysgit/msysgit and download the latest version from the master branch

Unzip it let's say to c:/tmp/git/msygit-env

2. Download the latest version of git

Head up to the Github page https://github.com/msysgit/git and download the latest version from the master branch

Unzip it let's say to c:/tmp/git/git

3. Copy the git folder

Now copy the entire contents of the c:/tmp/git/git under c:/tmp/git/msygit-env/git

4. Build Git

Now you can fire up a DOS console and head up to the msysgit and build Git


cd c:/tmp/git/msygit-env
msys.bat

Once the build starts you should see some output similar to

-------------------------------------------------------
Building and Installing Git
-------------------------------------------------------
GIT_VERSION = 2.1.0
    * new build flags
    CC credential-store.o
    * new link flags
    CC abspath.o
    CC advice.o
    CC alias.o
    CC alloc.o
    CC archive.o
    CC archive-tar.o

5. Moving the binaries and updating the path

Once the build is finished you will find the git binaires under the /bin folder

So let's say for example that I want to put my git binaries under c:/dev/bin/git2 go ahead and copy the following folders from the c:/tmp/git/msygit-env/git :

  • bin
  • cmd
  • etc
  • include
  • lib
  • libexec
  • mingw
  • share
  • ssl

Please note that I don't think you actually need all those folders but I copied them all just to be sure ..

Now for the final step the PATH; you will need to add the following folders to your PATH :

$PATH;C:\dev\bin\git2\bin;C:\dev\bin\git2\mingw\bin;C:\dev\bin\git2\cmd

Once the cmd prompt restarted you should be able to use your newly build Git

git --version
git version 2.1.0

And there you go if everything went as expected you should be running git 2.x

NodeJS, tune or disable HTTP agent pooling

When using NodeJS's HTTP module to query you might end-up having performance problems if you do some heavy HTTP querying.

By default when executing queries using the HTTP module NodeJS will use connection pooling with the maximum number of connection sockets being 5, so if you hit the bottleneck your HTTP queries will lag as they will be queued.

To my knowledge you have 2 options to "counter" this behavior :

  1. Increase the number of http sockets
  2. Disable the HTTP agent per request

1. Increase the number of http sockets

    var http = require('http');

    // increase the maximum number of http connections in the pool
    http.globalAgent.maxSockets = 100;

    //regular http request options
    var options = {
        port: 1337,
        hostname: '127.0.0.1',
        method: 'GET',
        path: '/test'
  };

  // make http query
  var req = http.request(options, function(res) {
       console.log('STATUS: ' + res.statusCode);
       console.log('HEADERS: ' + JSON.stringify(res.headers));
       res.setEncoding('utf8');
       res.on('data', function (chunk) {
          console.log('BODY: ' + chunk);
      });
   });



2.Disable the HTTP agent per request


    var http = require('http');
  
      //regular http request options
      var options = {
         port: 1337,
         hostname: '127.0.0.1',
         method: 'GET',
         path: '/test',
         agent:false //disable the nodejs agent (no connection pooling)
      };

      // make http query
      var req = http.request(options, function(res) {
       console.log('STATUS: ' + res.statusCode);
       console.log('HEADERS: ' + JSON.stringify(res.headers));
       res.setEncoding('utf8');
       res.on('data', function (chunk) {
          console.log('BODY: ' + chunk);
      });
   });

Please be aware that changing this options might have side effects on your host system such as higher memory and bandwidth use so use it wisely

OSX show used ports or listening applications with their PID

On OSX you can display applications listening on a given port using the lsof the commands described below will show listening application...