Skip to content

Instantly share code, notes, and snippets.

@zwade
Last active February 10, 2023 18:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zwade/1a44b09e7ee3e63f16843ded00a04cd2 to your computer and use it in GitHub Desktop.
Save zwade/1a44b09e7ee3e63f16843ded00a04cd2 to your computer and use it in GitHub Desktop.
Code Review Rangiri

Code Review Rangiri

Setup

This is part of a broader set of tools used to make it easier to split one large change into many.

Move these two commands into a user-writable bin folder (I personally user ~/bin, but you may prefer /usr/local/bin or similar).

Usage

To start dicing, run git set-grab-head <ref-to-full-commit>. Then, as you build out your chain of commits, you can use git grab <file> <file> ... to copy state from the grab head to the local index.

Rebasing

Maintaining a chain of PRs in GitHub is annoying, so I made a utility called git rebase-chain to assist. You can install it with pip install git-rebase-chain.

For more documentation, see https://github.com/zwade/git-rebase-chain

#!/bin/bash
git checkout --no-overlay grab-head $@
#!/bin/bash
git update-ref refs/heads/grab-head ${1:-@}
#!/bin/bash
set -e
if [ "$(git diff-index @)" != "" ] && [ "$1" != "--hard" ]; then
echo "You have uncommitted changes. Please commit them first."
exit 1
fi
BRANCH=$(git rev-parse --symbolic-full-name --abbrev-ref HEAD)
if [ "$BRANCH" = "HEAD" ]; then
echo "You are not on a branch. Please checkout a branch first."
exit 1
fi
git push origin -f @:refs/heads/$BRANCH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment