package git-split

  1. Overview
  2. Docs
A tool to split a git commit into multiple

Install

Dune Dependency

Authors

Maintainers

Sources

1.0.0.tar.gz
md5=1f1860b4bc51aef953abd223faa5d577
sha512=b6060d07af166a3b44a88a12819e58c0b02a73926c7210f3d144419a9a2ccbd82c8ce91e46ae6358cc0cb59f7828e9068f9ae8fafd22da285321af80e92cc657

Description

When one commit becomes too large and needs to be split up, the general git workflow that involves resetting the commit and then using interactive staging to generate multiple commits from it can be quite cumbersome. In addition to that, the git interactive staging tool's UX can be quite bad, therefore this tools aims to provide this functionality in a nicer way.

Published: 27 Oct 2024

README

git split

TUI-based commit splitting tool for git.

Why does this exist?

For those of us who like keeping their commit history clean, sometimes it may happen that a single commit ends up containing more functionality than we'd like. For these cases the main solution is to do a soft reset on the commit and start using git add -p to pick what you want in your commit, leaving the rest for another commit. That tool operates mostly on a hunk-by-hunk basis and when you'd like to go for line-by-line adding, the UX gets pretty bad, which led me to build this.

How do I use this?

Ideally you'd install it in a directory of your choosing that is on the path, as this ensures you can simply run git split instead of git-split.

You can install this via opam or clone the repository and build with dune. Ready-made binaries are also available with the releases. Homebrew support might come.

After installation, simply run

git split

which defaults to selecting the HEAD commit or

git split <commit-id>

which splits a specific commit.

The tool will ensure that any commit on the branch that comes after the one you are about to split will be rebased on top the last commit generated by the split, unless you abort the process.

Additional options to consider are --example which gives you an example set of change so you can explore the tool and --view-only which will allow you to look at a specific commit, but not really split it.

How does this work?

This tool works by parsing the diff of the commit you are trying to split and re-assembling a diff after confirming the lines you want to keep. (Another option I considered was to keep the total changeset in the memory and let the commits be created afterwards, but I suspected this would overall be a worse UX).

Demo

NB!

The goal of this project was to learn OCaml, so if you are an OCaml expert reading this and despairing at the code quality, feel free to open a discussion with improvement suggestions.

Dependencies (5)

  1. ppx_deriving
  2. notty
  3. angstrom >= "0.16.1"
  4. dune >= "3.15"
  5. ocaml >= "4.14"

Dev Dependencies (2)

  1. odoc with-doc
  2. alcotest with-test

Used by

None

Conflicts

None

OCaml

Innovation. Community. Security.