Giter Club home page Giter Club logo

git-instafix's Introduction

git instafix

Quickly fix up an old commit using your currently-staged changes.

usage

Usage

After installation, just run git instafix to commit your currently-staged changes to an older commit in your branch.

By default, git instafix checks for staged changes and offers to amend an old commit.

Given a repo that looks like:

linear-repo

Running git instafix will allow you to edit an old commit:

linear-repo-fixup

The default behavior will check if your current HEAD commit has an upstream branch and show you only the commits between where you currently are and that commit. If there is no upstream for HEAD you will see the behavior above.

If you're using a pull-request workflow (e.g. github) you will often have repos that look more like this:

full-repo

You can set GIT_INSTAFIX_UPSTREAM to a branch name and git instafix will only show changes between HEAD and the merge-base:

full-repo-fixup

In general this is just what you want, since you probably shouldn't be editing commits that other people are working off of.

After you select the commit to edit, git instafix will apply your staged changes to that commit without any further prompting or work from you.

Adding the --squash flag will behave the same, but after you have selected the commit amend to git will give you a chance to edit the commit message before changing the tree at that point.

Installation

You can install the latest version with curl:

curl --proto '=https' --tlsv1.2 -LsSf https://github.com/quodlibetor/git-instafix/releases/latest/download/git-instafix-installer.sh | sh

If you have Homebrew (including linuxbrew) you can install it with:

brew install quodlibetor/git-tools/git-instafix

You can also install from this repo with cargo:

cargo install --git https://github.com/quodlibetor/git-instafix

Otherwise, you will need to compile with Rust. Install rust, clone this repo, build, and then copy the binary into your bin dir:

curl https://sh.rustup.rs -sSf | sh
git clone https://github.com/quodlibetor/git-instafix && cd git-instafix
cargo build --release
cp target/release/git-instafix /usr/local/bin/git-instafix

Similar or related projects

  • git-absorb is a fantastic tool that will automatically determine which commits to amend. It is reliable, the main downside to it is that it relies on a diff intersection between your changes and ancestor commits, and so sometimes cannot determine which commits to amend.
  • git-fixup is more-or less a pure-shell version of this same tool. We have some different features. The big differences between git-fixup and git-instafix are pretty much all surface level, and git-instafix is written in Rust which allows for some slightly fancier interactions. git-instafix does not depend on the system it's being run on having a git binary, instead using libgit2 for all git interactions.

License

git-instafix is licensed under either of

at your option.

Patches and bug reports welcome!

git-instafix's People

Contributors

quodlibetor avatar guswynn avatar

Stargazers

Jay Beaton avatar Oliver Davies avatar Xianliang Ge avatar Fayaz Bin Salam avatar Shayon avatar Elian Doran avatar  avatar  avatar Moritz Kitzmann avatar Doron Cohen avatar Arne  Christian Beer avatar Ilmari Vacklin avatar  avatar Steven Kalt avatar Yuval Kogman avatar Rafael Epplée avatar Ivan Chen avatar Oskar Karpiński avatar DCjanus avatar Sven-Hendrik Haase avatar GAURAV avatar Kevin Rathbun avatar Ben Lovy avatar Andy avatar

Watchers

 avatar James Cloos avatar

git-instafix's Issues

Do I need to be on a different branch?

I'm working locally on my main branch, tracking origin/main. I do trunk-based development, so rarely create topic branches.

My local branch is three commits ahead of the remote branch, but I get this error when running git instafix:

Error: selecting commit to amend: No commits between main (cfc2a5d253) and cfc2a5d253599bf6b36e636bc6fa918ca67cd4ab

Does git-instafix assume I'm working on a different branch and merging into something like main or master?

I expected it to allow me to select from my local commits that weren't yet pushed to my remote, and run a fixup on those.

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.