Autorebase automatically rebases all of your feature branches onto master.

Overview

Build Status

Autorebase

Autorebase automatically rebases all of your feature branches onto master. If conflicts are found it will rebase to the last commit that doesn't cause conflicts. By default, branches with an upstream are excluded. You don't need to switch to any branch, the only limitation is that a branch that is checked out and not clean will not be rebased (though I may add that in future).

Here is a demo. Before autorebase we have a number of old feature branches.

Let's autorebase!

This has attempted to rebase all of the branches. demo and readme were successfully rebased onto master. However the other branches had conflicts, so they were not rebased all the way to master. Instead they were rebased to just before the commit that caused the conflicts.

If a commit couldn't be fully rebased due to conflicts, it is marked as such and rebasing it won't be attempted again until its commit hash changes (e.g. to being edited or manually rebased).

Installation

Download a binary release from the Github releases page, or you can run

cargo install autorebase

Usage

Just run autorebase in your repo. This will perform the following actions

  1. Update master, by pulling it with --ff-only unless you have it checked out with pending changes.
  2. Create a temporary work tree inside .git/autorebase (this is currently never deleted but you can do it manually with git worktree remove autorebase_worktree).
  3. Get the list of branches that have no upstream (except with --all-branches), and aren't checked out with pending changes.
  4. For each branch:
    1. Try to rebase it onto master.
    2. If that fails due to conflicts, abort and try to rebase it as far as possible. There are two strategies for this (see below).
    3. If we didn't manage to rebase all the way to master, then mark the branch as "stuck" so it isn't attempted in future. To "unstick" it, rebase manually or add more commits to the branch.

Full usage is:

autorebase
    [--slow]
    [--all-branches]
    [--onto ]

is master by default. If you develop on develop you probably want autorebase --onto develop.

There are two strategies to deal with conflicts. The default is fast; --slow selects the slow method. The slow method simply tries rebasing onto master^, master^^, master^^^ and so on until one works or we get to the merge base.

The fast method tries to rebase master onto the feature branch. It counts how many commits succeed, and assumes that these ones don't conflict, and the next commit must be the offending one. Then it aborts the rebase and rebases the feature branch to just before that commit.

The slow method is reliable but slow. The fast method is fast but may be suboptimal in some case, for instance if a conflict is only introduced temporarily.

Limitations

  • It probably won't be able to rebase branches that aren't trees, i.e. branches that contain merge commits. I haven't really tested this.
  • It does everything by running git on the command line rather than through a library like libgit2, which probably isn't super robust.
  • There's no way to manually specify which branches to rebase. I may add an interface like autorebase track my_branch at some point. Maybe.
  • autorebase's worktree is never deleted so it uses up some disk space forever. You can delete it manually if you like.
  • Limited testing!
You might also like...
`fugit` provides a comprehensive library of `Duration` and `Instant` for the handling of time in embedded systems, doing all it can at compile time.

fugit fugit provides a comprehensive library of Duration and Instant for the handling of time in embedded systems, doing all it can at compile time. T

A Monte Carlo simulation of getting all possible outcomes of loot boxes opening

lootboxes_monte_carlo A monte-carlo simulation of the number of "lootboxes" to open to get at least one of each possible outcome I wondered how many l

A project for managing all Pop!_OS sources

Pop!_OS Pop!_OS is designed for people who use their computer to create; whether it’s complicated, professional grade software and products, sophistic

A repo to store all my 6-Month Rust learning steps

RustLearn A repo to store all my 6-Month Rust learning steps. (free time only!) at the end of the 6-month course, the repo will be a rust package for

Scan all IP nodes of CloudFlare to find the fastest IP node.
Scan all IP nodes of CloudFlare to find the fastest IP node.

中文版 | English 📖 Introduction Scan all IP nodes of CloudFlare to find the fastest IP node. ⚡️ Get Started 🔨️ Build git clone https://github.com/golan

The simplest way to de-Google your life and business: Inbox, Calendar, Files, Contacts & much more
The simplest way to de-Google your life and business: Inbox, Calendar, Files, Contacts & much more

Bloom The all-in-one private workspace Try it for free! You no longer trust tech monopolies with your data? You are done with your privacy invaded by

EmPOWer your commits with Rust!

git-power-rs What is this? Make your git tree into a blockchain! Inspired by this project, I noticed that there was a call to Rewrite it in Rust™, so

Play Onitama in your browser, compete with friends or lose to a bot

Play Onitama in your browser, compete with friends or lose to a bot

Tells you how many years you need to wait until your subatomic xeon crystal synchronizer has doubled in plasma inversion efficiency on the Goldberg-Moleman scale or whatever.

about Tells you how many years you need to wait until your subatomic xeon crystal synchronizer has doubled in plasma inversion efficiency on the Goldb

Comments
  • Consider disabling signing when experimenting

    Consider disabling signing when experimenting

    The commit.gpgsign option adds 300ms+ of latency to each commit, making a large rebase take minutes instead of seconds.

    Can the tool toggle it off? Explicitly opt out?

    I'd like it on for the final rebase of the branch, as the commits should be signed on the final branch, but there's no need for it to be on (slowing everything down) while messing around?

    opened by FauxFaux 1
  • feat: --all-branches

    feat: --all-branches

    A flag, --all-branches, which causes us to also rebase branches with an upstream.

    I don't use the upstream feature (i.e. have branches pushed to matching), so whether things have an upstream is pretty much random.

    opened by FauxFaux 0
  • Does not work if run from a worktree

    Does not work if run from a worktree

    If you make a git repository at /foo and then make a worktree at /bar then run autorebase in /bar it fails with a message like this:

    • Creating worktree...
    Error: process exited with exit code exit code: 128
    Command: ["git", "worktree", "add", "--detach", "/bar/.git/autorebase/autorebase_worktree"]
    Stdout: Preparing worktree (detached HEAD 7866eaea0a)
    
    Stderr: fatal: could not create leading directories of '/bar/.git/autorebase/autorebase_worktree/.git': Not a directory
    
    opened by Timmmm 0
  • Recover from a crash, by cleaning the worktree

    Recover from a crash, by cleaning the worktree

    If the app crashes, it leaves the worktree in the middle of a rebase, from which it can't recover.

    • Pulling master...
    Error: process exited with exit code exit status: 128
    Command: ["git", "switch", "master"]
    Stdout: 
    Stderr: fatal: cannot switch branch while rebasing
    Consider "git rebase --quit" or "git worktree add".
    

    I fixed it with git worktree remove autorebase_worktree --force, maybe it could do it automatically.

    (hi from reddit!)

    opened by FauxFaux 1
Releases(0.4.5)
Owner
Tim
Tim
A GitHub Action to automatically build and deploy your mdbook project.

?? deploy-mdbook The deploy-mdbook action allows you to easily build and deploy your mdBook project to GitHub Pages. See action.yml for configuration

null 27 Oct 24, 2022
A simple, yet feature-filled wrapper around the coqui-stt C API

A simple, yet feature-filled wrapper around the coqui-stt C API

0/0 56 Jan 3, 2023
Fetch all your fetches, but in rust

fetchfetch, but in rust Fetch all of your fetches. written in go rust. Installation You can either download the latest release or build from source (r

null 4 May 7, 2023
Adds size optimizations to any Perseus app automatically.

Perseus Size Optimization Plugin WARNING: Until Perseus #66 is fixed, this plugin can actually increase overall binary size! Once that issue is fixed

arctic_hen7 6 Aug 14, 2022
Automatically download minecraft server jars in one line

MCDL Automatically download minecraft server jars in one line (or one click) Installation Download (Windows, Linux) Install via cargo: cargo install m

Isaac Hirschfeld 1 Oct 26, 2021
🛡️ 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.

Branch Autoprotector 2 Jan 31, 2022
A dynamic output configuration tool that automatically detects and configures connected outputs based on a set of profiles.

shikane A dynamic output configuration tool that automatically detects and configures connected outputs based on a set of profiles. Each profile speci

Hendrik Wolff 15 May 4, 2023
🛠️ | System tool for all my lovers

<<<<<<< HEAD ?? love-fetch Original code ferris-fetch ?? ??️ System tool for all my lovers ?? How to install it ?? cargo install love-fetch License ??

Fabio Grimaldi 11 Jun 13, 2021
One-Stop Solution for all boilerplate needs!

One Stop Solution for all boilerplate needs! Consider leaving a ⭐ if you found the project helpful. Templa-rs Templa-rs is a one-of-a-kind TUI tool wr

IEEE VIT Student Chapter 27 Aug 28, 2022
🦴🤖 // A Discord bot about collecting all the Borpa

?? ?? Borpa Bot Borpa Bot is a Discord bot about collecting all the Borpa possible. If you dont know what a Borpa is you can find it here Crate Descri

mellowmarshe 1 Dec 19, 2021