GIT REST API
The aim of the project is to provide a restful Git API that mimics as most as possible the old good git.
For example, in order to commit a change in shell you should do:
$ mkdir new-project$ cd new-project$ git init$ git add file.c$ git commit -m 'A commit message'$ git add file.c$ git commit -m 'A second commit message'$ git show HEAD~:file.c
In case of git-rest-api
you should do:
POST /init
Install
In your project install git-rest-api and express:
$ npm install git-rest-api$ npm install express
Environment variables
The following environment variables are supported:
PORT
: port to serve at, default is8080
PREFIX
: string prefix to serve repositories at, i.e.http://localhost:[port]/[prefix]/repo/:repo/tree/:path
TMPDIR
: name of temporary directory to use to cache repositoriesLOGLEVEL
: log level for winston logger. Default iserror
Example servers
Example 1: A simple example of a server running git-rest-api
:
var app = git = ; git;
Example 2: All actions on repositories are specific to the client session.
To share repositories between sessions/cookies, pass an existing path to workDir
in the init config
, e.g.
mkdirp = ;var WRKDIR = './wrk-test-git';mkdirp;git;
Example 3: For a dockerized version, check docker-node-git-rest-api
Example clients
- git-rest-api-client-php
- Can also be used as a flysystem adapter via flysystem-git
Testing
- For direct testing on your local machine:
npm install
followed bynpm test
- For using the provided vagrant virtual environment:
cd vagrant
followed bymake
- To increase verbosity:
export LOGLEVEL=info