Giter VIP home page Giter VIP logo

autorebase's Introduction

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 <target_branch>]

<target_branch> 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!

autorebase's People

Contributors

fauxfaux avatar timmmm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

autorebase's Issues

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!)

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?

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.