Giter Site home page Giter Site logo

gitreb's Introduction

GitReb

A small interface over git rebase -i's common usage

  • Easy non-interactive interactive rebasing with action applied only to specified revision;

  • Allows using :/<text> notation easily;

  • Uses --root if needed to apply action to root commit.

Usage

gitreb <action> <revision>

This does the same as calling git rebase -i <revision>^ and then replacing the first word with <action> in EDITOR.

To use as a git subcommand, insert the following in your .gitconfif:

[alias]
    autorebase = ! /path/to/gitreb/script

You can then do:

git autorebase edit :/some nasty bug

Special cases

  • If <revision> is the root commit, then GitReb does the same as calling git rebase -i --root and replacing the first word with <action>.

  • If <revision> uses the :/<text> notation, then GitReb does the same as calling git rebase -i HEAD^{/<text>}^.

    This is not explicitely coded, merely the only side-effect of using git rev-parse to find the commit then applying <commit>^ to the result.

    AFAIK, :/<text> is the only notation to which you can't just apply the lone caret modifier.

Idea

I wanted to be able to use the following command intuitively:

$ git rebase -i :/<text>^   # DOES NOT DO AS EXPECTED

I wrote this on Stack Overflow which describes the situation.

I also don't like having to use EDITOR for such a simple to describe operation.

This StackOverflow comment mostly answers both concerns by using git rev-parse and $GIT_SEQUENCE_EDITOR with sed -i.

I was compelled to

  • use ed which unlike sed is supposed to edit files in place,
  • make the script shell-agnostic,
  • use default edit behaviour instead of always using reset HEAD^, (though you could still reuse the selected commit message with commit -c, I didn't want the default behaviour to change).
  • Use <commit>^ instead of <commit>^^,
  • Use --root if needed

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.