https://github.com/charpeni/merge-drivers-cli
A command-line interface to conveniently manage custom git merge drivers.
https://github.com/charpeni/merge-drivers-cli
git merge-driver merge-drivers
Last synced: about 1 year ago
JSON representation
A command-line interface to conveniently manage custom git merge drivers.
- Host: GitHub
- URL: https://github.com/charpeni/merge-drivers-cli
- Owner: charpeni
- License: mit
- Created: 2023-10-19T17:02:38.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-10T16:48:36.000Z (over 1 year ago)
- Last Synced: 2025-04-09T23:07:28.241Z (about 1 year ago)
- Topics: git, merge-driver, merge-drivers
- Language: JavaScript
- Homepage:
- Size: 90.8 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Merge Drivers CLI

[](https://www.npmjs.org/package/merge-drivers)
[](https://www.npmjs.org/package/merge-drivers)
[](https://github.com/charpeni/merge-drivers-cli/blob/main/LICENSE)
A command-line interface to conveniently manage custom git merge drivers.
## Why
Git offers the ability to define two types of custom merge drivers. The first one is global, accessible through `~/.gitconfig`. The second one is local, accessible through `.git/config`. The problem is that the configuration of these drivers is not very convenient as neither of these solutions are versioned.
This CLI aims to solve this problem by providing a simple and intuitive interface to manage these drivers.
[📚 Use Custom Merge Driver to Simplify Git Conflicts](https://www.charpeni.com/blog/use-custom-merge-driver-to-simplify-git-conflicts).
## Usage
Merge drivers are defined within a configuration file that should be living at the root of your project named as `.merge-drivers.yml`. This file is a YAML file that should contain a list of drivers (under `merge-drivers` key). Each driver is defined by a key, name, and a driver (command). Here is an example of such a file:
```yaml
merge-drivers:
yarn:
name: 'yarn merge driver'
driver: 'yarn install'
```
From there, you will be able to use the following commands:
Ideally, we would like to automate the installation of those merge drivers.
> [!WARNING]
> It could be achieved by using a `prepare` script in your `package.json` file. However, it may not possible depending on your package manager (_e.g., Yarn 2 and above don't execute `prepare`, so you would want to look into `postinstall`, see [Husky documentation for Yarn 2+](https://typicode.github.io/husky/getting-started.html#yarn-2) as a good reference_).
### Install
Installs merge drivers based on the provided config.
> [!NOTE]
> Automatically executes `clean` command before installing, unless `--no-clean` is specified.
```sh
npx merge-drivers install [merge-drivers...] [--no-clean]
```
### Uninstall
Uninstalls merge drivers based on the provided config.
```sh
npx merge-drivers uninstall [merge-drivers...] [--no-clean]
```
### Clean
Cleans merge drivers by uninstalling the ones that are disabled based on the provided config.
> [!NOTE]
> Automatically executed as part of `install` command, unless `--no-clean` is specified.
```sh
npx merge-drivers clean
```
## License
merge-drivers is [MIT licensed](LICENSE).