git-server-windows is a simple, easy to configure git server specifically designed for Windows. It works around the common SPAWN error regarding the execution of
git-receive-pack. It supports authentication.
git for Windows needs to be installed on the machine prior to running
# npm install git-server-windows
git-server-windows uses two batch files in order to execute certain git commands. Those batch files need to be located in the path you're running your git server.
# copy node_modules/git-server-windows/*.cmd .
The files are called
After copying those files, your project folder should at least contain the following elements:
index.js // your server implementation node_modules git-receive-pack.cmd git-upload-pack.cmd
Every git repository on your server must be initialized as a bare repository before it can be used with the server.
First create a subfolder for the repositories inside your project folder:
# md repos # cd repos
Then (for each planned repository) create a subfolder inside the repos folder:
# md myRepository # cd myRepository # git init --bare
For a basic server put this into your
// This is a simple example for a basic git server with no authenticationvar Git = ;Git;
# node index.js Git Server listening on port 8080 ...
In this example, let's assume you already have a local git repository which you want to store on your newly created git server. You can do this by adding a
remote to your git project which points to the server:
# git remote add myserver http://xxx.xxx.xxx.xxx:8080/git/myRepository
and then pushing your code to this remote:
# git push -u myserver master
The git server can be configured using a parameter object on creation:
port: 8080baseURL: '/git'repoDir: 'repos'defaultUsers:repositories: OBJECT
By default the server will be started on port 8080, using
/git as the base URL,
repos as the subfolder name of your repositories and an empty user list. All of the subfolders of
repos will be used as repositories.
baseURL configuration parameter is used to determine the base URL part of your git URL.
Example: If you want to access your server as
http://xxx.xxx.xxx.xxx:8080/mygit/REPOSITORYNAME you'd have to set
repoDir configuration parameter defines the name of the project subfolder that contains the git repositories.
defaultUsers is an array of
Git.User objects. If you specify such a list, the repository users will have to authenticate before they can
push to the repository:
var myUser =username: 'myusername'password: 'mypassword';Git;
By default, every subfolder of the folder specified by
repoDir will be used as a repository with the users specified by
If you want to change the list of users that can authenticate themselves against a repository on a per-repository basis, you can use the
repositories configuration parameter:
In this example, users need to authenticate to every repository but
var myUser =username: 'myusername'password: 'mypassword';var anotherUser =username: 'myotherusername'password: 'myotherpassword';Git;
In this example, the user
myUser can authenticate against every repository but
myOtherRepository which requires
anotherUser to authenticate.