Overview of git-branchless-lib
mastergit-branchless-lib is the supporting library for the git-branchless toolset. It provides the core logic and shared functionality used by the various git-branchless components.repository·master·Indexed 26 days ago
https://github.com/arxanas/git-branchlessA suite of tools for Git providing a branchless workflow, including patch-stacking, divergent development, and high-performance operations for large-scale repositories. Key features include `git undo` for reversing complex operations, `git smartlog` (git sl) for advanced history visualization, and `git restack` for repairing commit graphs. Version 0.11.1 includes supporting libraries like git-branchless-lib and scm-bisect for identifying bad commits in a DAG.
git-branchless-lib is the supporting library for the git-branchless toolset. It provides the core logic and shared functionality used by the various git-branchless components.scm-bisect provides reusable algorithms designed to identify the first bad commit within a directed acyclic graph (DAG). It is intended to function similarly to git-bisect but is architected to support various source control management (SCM) systems.git-branchless is a suite of tools designed to enhance Git workflows, specifically focusing on patch-stacking, prototyping, and high-performance operations in large repositories.
git undo for general-purpose undoing of commits, merges, rebases, and branch operations; git smartlog for advanced history visualization; and git restack for repairing broken commit graphs.git sync for rebasing all local stacks without checking them out, and git move for subtree manipulation.You can install git-branchless using your system's package manager or via Cargo. After installation, you must initialize the tool within your Git repository.
git branchless init inside your repository to complete the setup.git undo provides a high-level abstraction for reversing repository states. Unlike git reflog, which tracks individual reference movements, git undo can handle complex operations like rebases and branch deletions.
Supported operations:
Limitations:
git reset HEAD^ for this).git sl (smartlog) to visualize your commit history. Unlike git log --graph, which only shows commits with attached branches, git sl is designed for workflows where you rewrite the commit graph extensively. It also identifies abandoned commits (descendants of commits marked as rewritten as <hash>) that need to be repaired using git restack.The fix subcommand allows you to run a command and automatically amend the commits with any changes produced by that command. This is useful for automated bug fixing or linting.
Key behaviors:
apply_fixes logic to rewrite commits.move_options to determine how commits are rewritten (e.g., whether to force rewrite public commits).--on-disk option; use --in-memory instead.The split command allows you to extract changes from a single commit into separate commits. This is useful for breaking down large, monolithic commits into smaller, more manageable ones. The command can take a list of files to extract and supports different modes for how the extracted changes are integrated into the history.
When splitting, the command also handles restacking the descendants of the target commit to maintain a clean history.
The restack command automates the process of fixing a broken commit graph caused by rewrites (like git commit --amend). When a commit is amended or rewritten, its descendants become 'abandoned' because they are still based on the old, now-obsolete commit. restack finds these abandoned commits and rebases them onto the new, rewritten versions of their parents, restoring a continuous history.
This command can be applied to specific commits using revsets or to all obsolete commits in the repository.
When calling undo() with interactive: true, a TUI is launched. The interface provides a visual commit graph and a numbered list of events.
TUI Commands:
h / ?: Show helpq / Q: Quitn / N / Right: View next statep / P / Left: View previous stateg / G: Go to a specific event ID (opens a dialog to enter an ID)Enter: Revert the repository to the currently selected state (requires confirmation in the terminal)The record command allows you to commit changes from your working copy. It supports several modes of operation:
--fixup <revset> to create a commit that is intended to be combined with an existing commit.--stash to create a temporary commit of your current changes and then checks out the previous commit (effectively a stash).--insert to move the current commit and its descendants to be siblings of the current HEAD, effectively inserting a new commit into the history.Key features include support for untracked files via a configurable strategy and the ability to specify a new branch name during creation.
If you accidentally hide or unhide commits, you can revert the operation using the git undo command. The hide and unhide commands will explicitly print the command to run if the operation can be undone.
Example output from hide:
To unhide these X commits, run: git undo