2.1.2 • Published 2 years ago

git-interface v2.1.2

Weekly downloads
124
License
MIT
Repository
github
Last release
2 years ago

git-interface

npm.io

Interface to work with a git repository in node.js

Installation

$ npm install git-interface --save

Usage

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

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

Documentation

.setDir(dir: string)

Set path to repository

git.setDir('/path/to/repository');

.init()

Initializes new git repo

git.init();

.clone(repository: string, dest: string)

clone repository repository to path dest

await git.clone('git@github.com:yarkeev/git-interface.git', '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()

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()

Push current branch to origin

await git.push();

.add()

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');

.fetch()

Download objects and refs from origin

await git.fetch();

.addRemote(name: string, url: string)

Add a remote

await git.addRemote('origin', 'git@github.com:yarkeev/git-interface.git');

.setRemote(name: string, url: string)

Set the url of a remote

await git.setRemote('origin', 'git@github.com:yarkeev/git-interface.git');

.getRemotes()

Gets list of remote names

await git.getRemotes();

.getRemoteUrl(name: string)

Gets a url of a remote by name

await git.getRemoteUrl('origin');

.reset()

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');

.getBranchName()

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');

.getConflictList()

Get list of conflicted files after merge

const conflictList = await git.getConflictList();

.getUncommittedList()

Get list of uncommitted files

const uncomittedList = await git.getUncommittedList();

.getLastChanges()

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');

.getLocalBranchList()

Get list of local branches

const branches = await git.getLocalBranchList();

.getRemoteBranchList()

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');
2.1.2

2 years ago

2.1.1

3 years ago

2.1.0

4 years ago

2.0.7

4 years ago

2.0.6

4 years ago

2.0.5

4 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.0

6 years ago

0.1.9

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

9 years ago

0.0.22

9 years ago

0.0.21

9 years ago

0.0.20

9 years ago

0.0.19

10 years ago

0.0.18

10 years ago

0.0.17

10 years ago

0.0.16

10 years ago

0.0.15

10 years ago

0.0.14

10 years ago

0.0.13

10 years ago

0.0.12

10 years ago

0.0.11

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago