# git-snapshot

> Take a snapshot of the directory - like 'git subtree split --squash'

Latest version **2.2.2** (published 2020-09-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install git-snapshot
pnpm add git-snapshot
yarn add git-snapshot
bun add git-snapshot
```

Provides the command `git-snapshot`.

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.2 |
| Published | 2020-09-05 |
| First published | 2019-07-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 7 |
| Unpacked size | 26.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | mob-sakai |
| Maintainers | mob-sakai |
| Keywords | module, package, cli, git, subtree, split, snapshot |

## Links

- npm: https://www.npmjs.com/package/git-snapshot
- Repository: https://github.com/mob-sakai/git-snapshot
- Homepage: https://github.com/mob-sakai/git-snapshot#readme
- Issues: https://github.com/mob-sakai/git-snapshot/issues
- npm.io page: https://npm.io/package/git-snapshot

## Dependencies (7)

- [chalk](https://npm.io/package/chalk.md) ^2.4.2
- [debug](https://npm.io/package/debug.md) ^4.0.0
- [execa](https://npm.io/package/execa.md) ^2.0.2
- [tempy](https://npm.io/package/tempy.md) ^0.3.0
- [yargs](https://npm.io/package/yargs.md) ^14.2.0
- [ignore](https://npm.io/package/ignore.md) ^5.1.4
- [fs-extra](https://npm.io/package/fs-extra.md) ^8.0.0

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 2.2.2 (latest) — 2020-09-05
- 2.2.0-beta.2 (beta) — 2019-10-28
- 2.2.1 — 2020-02-23
- 2.2.0 — 2019-10-28
- 2.2.0-beta.1 — 2019-10-28
- 2.1.0 — 2019-10-26
- 2.1.0-beta.4 — 2019-10-26
- 2.1.0-beta.3 — 2019-10-25
- 2.1.0-beta.2 — 2019-10-25
- 2.1.0-beta.1 — 2019-10-18
- 2.0.0 — 2019-10-16
- 2.0.0-beta.4 — 2019-10-16
- 2.0.0-beta.3 — 2019-10-16
- 2.0.0-beta.2 — 2019-10-16
- 2.0.0-beta.1 — 2019-10-16
- … 6 more at https://npm.io/package/git-snapshot/versions

## README

# git-snapshot

`git-snapshot` is a tool to _take a snapshot of the directory and creates/updates another branch_, like `git subtree split --squash`.

<img src="https://user-images.githubusercontent.com/12690315/69536339-27db2700-0fc1-11ea-8bff-06e531680e4c.png" width=128> 

[![npm](https://img.shields.io/npm/v/git-snapshot)](https://www.npmjs.com/package/git-snapshot)
[![npm (beta)](https://img.shields.io/npm/v/git-snapshot/beta)](https://www.npmjs.com/package/git-snapshot/v/beta)
![license](https://img.shields.io/npm/l/git-snapshot)
![downloads](https://img.shields.io/npm/dy/git-snapshot)
![release](https://github.com/mob-sakai/git-snapshot/workflows/release/badge.svg)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

## Summary

`git-snapshot` is a tool to _take a snapshot of the directory and creates/updates another branch_, like `git subtree split --squash`.

- `git-snapshot` is a sub-command of `git`
- Take a snapshot of the directory as a commit
- Simple and fast
- Unlike `git subtree split`, you can split from the directory in which you want

## To take a snapshot, `subtree split` vs `snapshot`

|`subtree split`|`snapshot`|
|--|--|
|`git subtree split --rejoin --prefix=path/to/target snapshot`|`git snapshot --prefix=path/to/target --branch=snapshot`|
|:+1: Official command<br>- Contain all history<br>:-1: Long commit log<br>:-1: No squash option<br>:-1: No support for moving target directory|- No history<br>:+1: Short commit log<br>:+1: Fast operation<br>:+1: Any target directory|
|<img src="https://user-images.githubusercontent.com/12690315/69534929-1ba19a80-0fbe-11ea-8dda-1fd3f95baa81.png" width=400>|<img src="https://user-images.githubusercontent.com/12690315/69534927-19d7d700-0fbe-11ea-94ad-c1f8e7fdb1f6.png" width=400>|

## Installation

### Global installation

Install globally (add to your `PATH`) and you can use **git-snapshot** as a git sub-command.

```bash
$ npm install -g git-snapshot 
```

### Local installation

For [Node modules projects](https://docs.npmjs.com/getting-started/creating-node-modules) we recommend installing **git-snapshot** locally.

```bash
$ npm install --save git-snapshot 
```

## Usage

### CLI Usage

```
usage: git snapshot --prefix=<path> --branch=<branch> --message=<message>
[--tag=<tag>] [--remote=<repository>] [--dry-run] [--cwd=<path>]

Required
  --branch, -b   the name of branch for split to                 [string] [required]

Options:
  --help, -h     Show help                                                 [boolean]
  --version, -v  Show version                                              [boolean]
  --prefix, -p   the name of the subdir to split out                        [string]
  --message, -m  commit message                                             [string]
  --author, -a   override the commit author                                 [string]
  --force, -f    allow force commit, tag, push                             [boolean]
  --tag, -t      tag name                                                   [string]
  --remote, -r   remote repository                                          [string]
  --dry-run, -d  skip publishing                                           [boolean]
  --debug        output debugging information                              [boolean]
  --cwd, -c      working directory                                          [string]
```

### Code Usage

```js
const gitSnapshot = require('git-snapshot')

// Options are the same as command line, except camelCase
// gitSnapshot returns a Promise
gitSnapshot({
  prefix: './Packages/SomePackage',
  branch: 'upm',
  message: 'Release 1.0.0',
  author: 'snapshot',
  force: false,
  tag: '1.0.0',
  remote: 'origin',
  dryRun: false,
  cwd: process.cwd(),
}).then(() => {
  // git-snapshot is done
}).catch(err => {
    console.error(`git-snapshot failed with message: ${err.message}`)
})
```

## License

MIT

## See Also

- GitHub page : https://github.com/mob-sakai/git-snapshot
- Changelog : https://github.com/mob-sakai/git-snapshot/blob/master/CHANGELOG.md
- npm page : https://www.npmjs.com/package/git-snapshot
- gitgraph.js (a git graph tool) : https://github.com/nicoespeon/gitgraph.js/tree/master/packages/gitgraph-js
- semantic-release (a npm release tool) : https://github.com/semantic-release/semantic-release

[![become_a_sponsor_on_github](https://user-images.githubusercontent.com/12690315/66942881-03686280-f085-11e9-9586-fc0b6011029f.png)](https://github.com/users/mob-sakai/sponsorship)

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