some interfaces for work with git repository

Usage no npm install needed!

<script type="module">
  import gitInterface from '';



Interface to work with a git repository in node.js


$ npm install git-interface --save


const { Git } = require('git-interface');

const git = new Git({
    dir: '/path/to/repository' //default path is current directory


.setDir(dir: string)

Set path to repository



Initializes new git repo


.clone(repository: string, dest: string)

clone repository repository to path dest

await git.clone('', 'git-interface');

.checkout(branchName: string)

Checkout to branch branchName

await git.checkout('master');

.updateSubmodules(init: boolean = true, recursive: boolean = true)

Updates the git submodules:

await git.updateSubmodules();

.commit(message: string)

Commit changes with message

await git.commit('message for annotate');


Pull current branch from origin

await git.pull();

Pull branch feature1 from remote test with rebase (-r) option

await git.pull('test', { branch: 'feature1', rebase: true });


Push current branch to origin

await git.push();


Add all new files to VCS

await git.add();

.merge(branchName: string, mergeOptions?: string)

Merge branch branchName to the current branch with flags mergeOptions

await git.merge('branch-name');
await git.merge('branch-name', '--squash');


Download objects and refs from origin

await git.fetch();

.addRemote(name: string, url: string)

Add a remote

await git.addRemote('origin', '');

.setRemote(name: string, url: string)

Set the url of a remote

await git.setRemote('origin', '');


Gets list of remote names

await git.getRemotes();

.getRemoteUrl(name: string)

Gets a url of a remote by name

await git.getRemoteUrl('origin');


Reset uncommitted changes

await git.reset();

.getHash(fileName: string)

Getting hash commit was last modified

const hash = await git.getHash('path/to/file');

.diffMaster(fileName: string)

File comparison fileName with master

const diff = await git.diffMaster('path/to/file');


Get name of the current brunch

const branch = await git.getBranchName();

.createBranch(branchName: string)

Create branch with name branchName

await git.createBranch('new-branch');

.deleteBranch(branchName: string)

Delete branch with name branchName

await git.deleteBranch('existing-branch');

.getDiffByRevisionFileList(revision: string)

Getting a list of files that have changed relative revision

const diffFileList = await git.getDiffByRevisionFileList('5e19a1d3c386a2607885627f3774d3d7746b60de');


Get list of conflicted files after merge

const conflictList = await git.getConflictList();


Get list of uncommitted files

const uncomittedList = await git.getUncommittedList();


Getting a list of files that have changed in the last commit

const lastChanges = await git.getLastChanges();

.removeLocalBranch(branchName: string)

Remove local branch branchName

await git.removeLocalBranch('branch-name');

.removeRemoteBranch(branchName: string)

Remove branch branchName from origin

await git.removeRemoteBranch('branch-name');


Get list of local branches

const branches = await git.getLocalBranchList();


Get list of remote branches

const branches = await git.getRemoteBranchList();

.getTimeOfLastCommit(branchName: string)

Get time of last commit in branch

const timeOfLastCommit = await git.getTimeOfLastCommit('branch-name');

.getHashOfLastCommit(branchName: string)

Get hash of last commit in branch

const hashOfLastCommit = await git.getHashOfLastCommit('branch-name');