From 6aa1403f0ba2807b1aea4e57bb2b21ec5a18c04b Mon Sep 17 00:00:00 2001 From: Florian Beisel Date: Wed, 30 Oct 2024 11:58:02 +0100 Subject: [PATCH] Add .local/bin/git-restage --- private_dot_local/bin/executable_git-restage | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 private_dot_local/bin/executable_git-restage diff --git a/private_dot_local/bin/executable_git-restage b/private_dot_local/bin/executable_git-restage new file mode 100644 index 0000000..2ccb234 --- /dev/null +++ b/private_dot_local/bin/executable_git-restage @@ -0,0 +1,17 @@ +#!/bin/sh + +# Stage all diffs found in currently staged files + +# This is useful if you've got a set of files ready to commit, but edited one +# or more of them (via prettier, delinting, deleting debug statements, adding +# more tests, ...), and want to make sure those changes are included. + +# Usage: `git restage` + +# Installation: add this script to your $PATH and chmod +x. + +# Hop down to the root of the repository so paths are correct: +cd "$(git rev-parse --show-toplevel)" || exit 1 + +# For all currently staged files, call `git stage`: +git diff --name-only --cached | xargs --verbose -n 1 -- git stage