dotfiles/.local/bin/scripts/git-moves

9 lines
297 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=.3 |
grep -vf /tmp/staged | cut -c4- | sed 's/ -> /\n/' |
xargs git -C "$root" restore --staged