dotfiles/.local/bin/scripts/git-moves
2021-11-17 15:55:46 +01:00

9 lines
329 B
Bash
Executable file

#!/bin/sh
# Stage moved files fitting the already staged ones
git diff --name-only --cached >/tmp/staged
root=$(git rev-parse --show-toplevel)
git add "$root"
git status --porcelain --find-renames=.2 |
grep -vf /tmp/staged | cut -c4- | sed 's/ -> /\n/' |
xargs git -C "$root" restore --staged
git status -s --find-renames=.2