tutorial: update the initial commit example.
[git.git] / git-add.sh
1 #!/bin/sh
2
3 show_only=
4 verbose=
5 while : ; do
6   case "$1" in
7     -n)
8         show_only=true
9         verbose=true
10         ;;
11     -v)
12         verbose=true
13         ;;
14     *)
15         break
16         ;;
17   esac
18   shift
19 done
20
21 GIT_DIR=$(git-rev-parse --git-dir) || exit
22 global_exclude=
23 if [ -f "$GIT_DIR/info/exclude" ]; then
24    global_exclude="--exclude-from=$GIT_DIR/info/exclude"
25 fi
26 for i in $(git-ls-files --others \
27         $global_exclude --exclude-per-directory=.gitignore \
28         "$@")
29 do
30    [ "$verbose" ] && echo "  $i"
31    [ "$show_only" ] || git-update-index --add -- "$i" || exit
32 done