Stacked branch management for Git

Related tags

Utilities git-stack
Overview

git-stack

Stacked branch management for Git

Screenshot

codecov Documentation License Crates Status

Dual-licensed under MIT or Apache 2.0

Documentation

Status

This software is pre-release / prototype. We only recommend this for people who are willing to go the extra mile when filing bug reports. Extra effort is needed to create bug reports that are actionable as we need to iterate on how best to help people in creating good Issues. While we still need to spend more time hardening, we do not expect any data loss with default features.

About

Like Stacked-Diffs? git-stack is another approach to bringing the Stacked Diff workflow to PRs that aims to be unintrusive to a project's workflow. Branches are the unit of work and review in git-stack. As you create branches on top of each other (i.e. "stacked" branches), git-stack will takes care of all of the micromanagement for you.

Unfamiliar with Stacked-Diffs? git-stack helps keep all of your local branches up-to-date, especially when you have a branches off of branches (i.e. stacked)

For example, from your development branch, run:

jira-3423423 $ git-stack --pull

git-stack:

  1. Auto-detects your parent remote branch (e.g. main).
  2. Performs a git pull --rebase <remote> <parent>
  3. Rebases jira-3423423 (and any dev branches on the stack) onto <parent>
  4. Shows the stacked branches

The closest equivalent is:

jira-3423 $ git checkout main
main $ git pull --rebase upstream main
main $ git checkout jira-3154
jira-3154 $ git rebase HEAD~~ --onto main
jira-3154 $ git checkout jira-3259
jira-3259 $ git rebase HEAD~ --onto jira-3154
jira-3259 $ git checkout jira-3423
jira-3423 $ git rebase HEAD~ --onto jurao-3259
jira-3423 $ git log --graph --all --oneline --decorate main..HEAD

Parent branch auto-detection works by separating the concept of upstream-controlled branches (called "protected branches") and your development branches.

Features:

  • Upstream parent branch auto-detection
  • Maintain branches relative to each other through rebase
  • Defers all permanent changes until the end (e.g. HEAD, re-targeting branches), always leaving you in a good state (similar to git revise)
  • Separates out pull/push remotes for working from a fork
  • On --push, detects which branches are "ready" (e.g. root of stack, no WIP)

Non-features

  • Conflict resolution: git-stack will give up and you'll have to use git rebase yourself to resolve the conflict.

To see how git-stack compares to other stacked git tools, see the Comparison.

Install

Download a pre-built binary (installable via gh-install).

Or use rust to install:

cargo install git-stack

Getting Started

Configuring git-stack

Protected branches: run git-stack --protected -v to test your config

  • To locally protect additional branches, run git-stack --protect <glob>.
  • When adopting git-stack as a team, you can move the protected branches from $REPO/.git/config to $REPO/.gitconfig and commit it.

Pull remotea when working from a fork (upstream is a different remote than origin), in $REPO/.git/config, set stack.pull-remote to your remote.

To see the config, run git-stack --dump-config -.

For more, see Reference.

Using

# Update branches against upstream
git-stack --pull

# Start a new branch / PR
git switch -c feature1
git add -A; git commit -m "Work"
git add -A; git commit -m "More Work"
git add -A; git commit --fixup HEAD~~

# See what this looks like
git-stack

# To push whats ready
git-stack --push

FAQ

How do I stack another branch (PR) on top of an existing one?

  • Append: git switch feature1 && git switch -v feature2 and start adding commits
  • Move: git rebase HEAD~~ --onto feature1
  • Move: git-stack --rebase --base HEAD~~ --onto feature

How do I add a commit to a branch (PR)?

  • If this is for fixing a problem in a previous commit, git commit --fixup <ref> and then git-stack --rebase will move it to where it needs to be.
  • If this is to append to the PR, for now you'll have to use git rebase -i

How do I start a new feature?

  • git switch feature1 && git switch -c feature2 and start adding commits

Why don't you just ...?

Have an idea, we'd love to hear it! There are probably git operations or workflows we haven't heard of and would welcome the opportunity to learn more.

How do I stack my PRs in Github?

Currently, Github is limited to showing all commits for a branch, even if some of those commits are "owned" by another PR. We recommend only posting one PR at a time within a stack. If you really need to, you can direct your reviewers to the commits within each PR to look at. However, you will see the CI run status of top commit for each PR dependency.

You might also like...
A git hook to manage derivative files automatically.

git-derivative A git hook to manage derivative files automatically. For example if you checked out to a branch with different yarn.lock, git-derivativ

Auto Fan Management Utility in Linux Systems for Monster Laptops
Auto Fan Management Utility in Linux Systems for Monster Laptops

Auto Fan Management Utility in Linux Systems for Monster Laptops Monster Laptoplar için Linux Sistemlerde Oto Fan Yönetimi TR Monster laptoplar gömülü

Simple and fast git helper functions

Simple and fast git helper functions

A lightning fast state management module for Yew.

yewv A lightning fast state management module for Yew built with performance and simplicity as a first priority. Who is this for? If you wish to use a

Verbump - A simple utility written in rust to bump and manage git semantic version tags.

Verbump - A simple utility written in rust to bump and manage git semantic version tags.

A git prepare-commit-msg hook for authoring commit messages with GPT-3.

gptcommit A git prepare-commit-msg hook for authoring commit messages with GPT-3. With this tool, you can easily generate clear, comprehensive and des

Easily add emojis to your git commit messages 😎
Easily add emojis to your git commit messages 😎

gimoji A CLI tool that makes it easy to add emojis to your git commit messages. It's very similar to (and is based on) gitmoji-cli but written in Rust

Command palette-style Git client for blazing-fast commits.
Command palette-style Git client for blazing-fast commits.

🔎 About Commit Commit is the world's simplest Git client. Open it with a keyboard shortcut, write your commit, and you're done! Commit will automatic

Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

Tiny Rust CLI to checkout a recent git branch interactively
Tiny Rust CLI to checkout a recent git branch interactively

git-select-branch Tiny Rust CLI to checkout a recent git branch interactively. Installation Homebrew brew tap dnjstrom/git-select-branch brew install

🧠 A command-line utility for switching git branches more easily. Switch branches interactively or use a fuzzy search to find that long-forgotten branch name.
🧠 A command-line utility for switching git branches more easily. Switch branches interactively or use a fuzzy search to find that long-forgotten branch name.

git-smart-checkout A git command extension for switching git branches more efficiently. About Interactively switch branches or fuzzy search for that f

Let Tauri's transparent background rendering window be stacked on Bevy's rendering window in real time to run the game with native-level performance!

Native Bevy with Tauri HUD DEMO 将 Tauri 的透明背景渲染窗口实时叠在 Bevy 的渲染窗口上,以使用原生级别性能运行游戏! Let Tauri's transparent background rendering window be stacked on Bev

GitHub CLI extension to show & rename the default branch.

gh-default-branch GitHub CLI extension to show & rename the default branch. rename subcommand was inspired by this gist. ⚠️ Caution The rename subcomm

🛡️ Automatically protect the default branch of new repositories in a GitHub organization

The Branch Autoprotector watches a GitHub organization and automatically protects the default branch in new repositories. This service notifies the creator of the default branch of this automatic branch protection setup by filing an issue in the repository.

The [cain!] macro is a macro that rewrites sequential Rust branch statements into nested branches

Note! This crate is experimental and under development. It may include bugs that alter the behavior of your code in unexpected ways. You should review

🍹Branch and bound solution using Rust to calculate an optimal cocktail ingredient list of arbitrary length 🍸

Calculating an Optimal Cocktail Ingredient List Tom Explains the Problem You have 100 different ingredients You have 20 cocktails, each of which use 2

Automatically commit all edits to a wip branch with GPT-3 commit messages

gwipt Automatic work-in-progress commits with descriptive commit messages generated by GPT-3 Codex Never again worry about the tension between "commit

A Rust CLI tool that helps you enforce Git policies through Git hooks both server and client side

GitPolicyEnforcer This is a command line utility written in Rust, that helps you utilize Git hooks, to enforce various policies. It currently supports

Releases(v0.6.0)
Owner
Ed Page
Ed Page
Original Version Management System based on Git

nss (noshishi) Original Version Management System based on Git. Learning git and rust for good developer. Usage Install cargo install nssi how to nss

nopeNoshishi 4 Feb 13, 2023
Simple git/hg tui client focused on keyboard shortcuts

verco A simple Git/Hg tui client focused on keyboard shortcuts Screenshots Platforms This project uses Cargo and pure Rust stable and works on latest

Matheus Lessa Rodrigues 214 Dec 26, 2022
🌌⭐ Git tooling of the future.

❯ Glitter Git tooling of the future. ❯ ?? Features Config files Fast Easy to use Friendly errors ❯ ?? Documentation For proper docs, see here ❯ ✋ What

Milo 229 Dec 22, 2022
An opinionated, practical color management library for games and graphics.

colstodian An opinionated color management library built on top of kolor. Introduction colstodian is a practical color management library for games an

Gray Olson 27 Dec 7, 2022
Estimate the amount of time spent working on a Git repository

jikyuu (時給) A tool to estimate the amount of time spent working on a Git repository. It is a direct port of git-hours, written in Node.js, because the

null 18 Nov 16, 2022
A small tool to clone git repositories to a standard location, organised by domain name and path.

A small tool to clone git repositories to a standard location, organised by domain name and path. Runs on BSD, Linux, macOS, Windows, and more.

Wesley Moore 68 Dec 19, 2022
Lintje is an opinionated linter for Git.

Lintje Lintje is an opinionated linter for Git. It lints commit messages based on a preconfigured set of rules focussed on promoting communication bet

Tom de Bruijn 26 Dec 18, 2022
Devmode is a project management utility for developers.

Dev(mode) Dev(mode) is a project management utility for developers.

Eduardo Flores 15 Dec 11, 2022
Replay git history with some tweaks

Git-replay Overview Git-replay is a simple tool that replays the history of a Git repository but with some tweaks (i.e., it can change the author name

Tak-gun Na 3 Mar 22, 2022
GRM — Git Repository Manager

GRM helps you manage git repositories in a declarative way. Configure your repositories in a TOML file, GRM does the rest.

Hannes Körber 32 Dec 30, 2022