tj.git-extras/bin/git-reset-file
2023-01-20 18:17:49 +08:00

18 lines
313 B
Bash
Executable file

#!/usr/bin/env bash
file="$1"
commit="$2"
if [[ -f $file ]]; then
git rm --cached -q -f -- "$file"
if [[ -z $commit ]]; then
git checkout HEAD -- "$file"
echo "Reset '$1' to HEAD"
else
git checkout "$commit" -- "$file"
echo "Reset '$1' to $commit"
fi
else
echo "File '$1' not found in $(pwd)"
fi