nowfound

Dev tools · June 12, 2015

GI

'git inject' – amend commits other than HEAD

'git inject' is a git alias (see code at the bottom). It is similar to 'git commit --amend', but it allows you to 'inject' your changes into commits further back in history (using 'rebase'). If you're as pedantic as I am about the git history you're about to push into master (as far as I can control it, I strive to keep each commit conceptually coherent), you'll often come to a situation where you have a modification that really belongs in an older commit. It takes a few git commands to stash other changes away, commit the modification, then interactively rebase over some previous commit,…

What it does

In the maker’s words, at launch

'git inject' is a git alias (see code at the bottom). It is similar to 'git commit --amend', but it allows you to 'inject' your changes into commits further back in history (using 'rebase'). If you're as pedantic as I am about the git history you're about to push into master (as far as I can control it, I strive to keep each commit conceptually coherent), you'll often come to a situation where you have a modification that really belongs in an older commit. It takes a few git commands to stash other changes away, commit the modification, then interactively rebase over some previous commit, move your commit into place, change to 'fixup', save, exit, and then unstash whatever else you had lying around. Not fun. Here's how 'git inject' makes it fun: >> git inject <commit-ref> <patch-ref> >> git inject HEAD^^ -a # inject all work-dir modifications >> git inject a28kd8 -p # interactively select patches to inject >> git inject HEAD~4 file1 # inject the modifications in file1 Just put this into your .gitconfig under 'aliases': inject = "!f() { set -e; HASH=`git show $1 --pretty=format:\"%H\" -q`; shift; git commit -m \"fixup! $HASH\" $*; [ -n \"$(git diff-files)\" ] && git stash && DIRTY=1; git rebase $HASH^^ -i --autosquash; [ -n \"$DIRTY\" ] && git stash pop;}; f"

Does the same job

all alternatives →

More dev tools this month

the category →
  • Dograh592

    The open source VAPI alternative

    Dev tools · 25d ago · dograh.com

  • Meridian530

    Don't let your work go unnoticed. Get promoted!

    Dev tools · 20d ago · meridiona.com

  • x1516

    Lovable for iPhone apps go from idea to App Store

    Dev tools · 11d ago · x1.new

  • Open-source GTM skills for technical founders

    Dev tools · 29d ago · gtmcofounder.com

  • OpenTrailPaper is open-source bike computer firmware for the LilyGO T5S3 4.7" E-Paper PRO. It supports offline maps, GPX routes, FIT recording and Bluetooth sensors.

    Dev tools · 1d ago · opentrailpaper.com

  • Nuphos380

    The AI-Native DevOps Workspace.

    Dev tools · 24d ago · nuphos.ai

Launched alongside, June 2015

the whole month →
  • A​rticles you need to read before launching a startup.

    Growth · 2015 · startuplaunchlist.com

  • Get any site's company logo with just a URL

    Dev tools · 2015 · clearbit.com

  • The best new games, every day

    Life & fun · 2015

  • Coverr584

    Beautiful, free videos for your homepage background.

    Work · 2015

  • SLIDE561

    A hoverboard by Lexus (no joke)

    Life & fun · 2015

  • The Best Landing Page Inspiration

    Work · 2015