# kgit

> A Simple & graceful git tool libary.

Latest version **0.1.3** (published 2020-09-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install kgit
pnpm add kgit
yarn add kgit
bun add kgit
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2020-09-30 |
| First published | 2020-02-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 16.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | 189 |
| Maintainers | 189 |
| Keywords | git |

## Links

- npm: https://www.npmjs.com/package/kgit
- Repository: https://github.com/189/kgit
- Issues: https://github.com/189/kgit/issue
- npm.io page: https://npm.io/package/kgit

## Dependencies (2)

- [tslint](https://npm.io/package/tslint.md) ^6.0.0
- [typescript](https://npm.io/package/typescript.md) ^3.8.2

## Recent versions

- 0.1.3 (latest) — 2020-09-30
- 0.1.2 — 2020-09-30
- 0.1.1 — 2020-09-30
- 0.1.0 — 2020-02-22

## README

A Simple & graceful git tool libary.

### Install

```
$ yarn add kgit
```


### API

####  getCurrentBranch: (repoDirPath: string) => Promise<string>
```
import { getCurrentBranch } from "kgit";

const repo = your_repo_path;
;(async function(){
    const branch = await getCurrentBranch(repo);
    console.log(branch)
})();

```

#### submitCommit
```
import { forceChangeBranch, clearGitRepo, submitCommit } from "kgit";

const repo = your_repo_path;
;(async function(){
    // Same as `git checkout -f master`
    await forceChangeBranch(repo, "master"); 

    // equal to `git reset --hard HEAD~5` && `git clean -f` && `git pull`
    await clearGitRepo(repo, 5);
    
    // it will work step by step:
    // step1: check submit is necessary（by check differences between the index file and the current HEAD commit ）
    // step2: git add -A
    // step3: git commit -m "your commit message"
    // step4: git push
    // step5: check push if success by comparing current HEAD and remote HEAD
    await submitCommit(repo, "your commit message")
})();
```

#### Some Api
> Works as theirs name.

- forceChangeBranch: (repoDirPath: string, branchName: string) => Promise<string>  
- resetHard: (repoDirPath: string, toPoint: string) => Promise<string>
- cleanCurrentBranch: (repoDirPath: string) => Promise<string>
- pullCurrentBranch: (repoDirPath: string) => Promise<string>
- clearGitRepo: (repoDirPath: string, toPoint: number = 1) => Promise<void>
- submitCommit: (repoDirPath: string, commitMessage: string, modifyFileChecker?: string | string[] | ModifyFileChecker | undefined) => Promise<boolean>;
- hasConflict: (repoDirPath: string) => Promise<boolean> 
- isUnmodified: (repoDirPath: string) => Promise<boolean>

---
_Source: https://npm.io/package/kgit · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
