forked from nvie/git-toolbelt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-skip
executable file
·40 lines (36 loc) · 952 Bytes
/
git-skip
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/sh
set -e
usage () {
echo "usage: git skip [-ah] <file> [<file> ...]" >&2
echo >&2
echo "Skip (ignore) local changes to git-aware files to prevent them from" >&2
echo "showing up in status reports or diffs, as if they haven't been changed" >&2
echo "locally at all." >&2
echo >&2
echo "To reset, use git-unskip." >&2
echo >&2
echo "Options:" >&2
echo "-a Skip all locally modified files" >&2
echo "-h Show this help" >&2
}
all=0
while getopts ah flag; do
case "$flag" in
a) all=1;;
h) usage; exit 2;;
esac
done
shift $(($OPTIND - 1))
locally_modified_files () {
git status --porcelain --untracked-files=no | cut -c 2- | grep -Ee '^[MD]' | cut -c 3-
}
if [ $all -eq 1 ]; then
git update-index --skip-worktree $(locally_modified_files)
else
if [ $# -gt 0 ]; then
git update-index --skip-worktree "$@"
else
usage
exit 2
fi
fi