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

10 lines
354 B
Plaintext
Raw Normal View History

2021-11-11 11:15:41 +00:00
#!/bin/sh
# Stage moved files fitting the already staged ones
git diff --name-only --cached >/tmp/staged
2021-11-11 16:31:53 +00:00
root=$(git rev-parse --show-toplevel)
git add "$root"
2021-11-17 14:55:46 +00:00
git status --porcelain --find-renames=.2 |
2021-11-11 16:31:53 +00:00
grep -vf /tmp/staged | cut -c4- | sed 's/ -> /\n/' |
xargs git -C "$root" restore --staged
test "$1" = "-q" || git status --short --find-renames=.2