Skip to content

Instantly share code, notes, and snippets.

@saku
Created April 22, 2014 04:01
Show Gist options
  • Save saku/11164976 to your computer and use it in GitHub Desktop.
Save saku/11164976 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ $# -lt 1 ]; then
echo "You need root path, which indicate you want clear git status"
exit 0
fi
rootPath=$1
echo "root path is $rootPath"
pushd $rootPath
#pwd
# set skip-worktree
for file in ${@:2:($#)}
do
if [ -f $file ]; then
git update-index --skip-worktree $file
fi
done
# git reset and file/dir remove
git clean -x -d -f
git reset HEAD --hard
# clear skip-worktree
for file in ${@:2:($#)}
do
if [ -f $file ]; then
git update-index --no-skip-worktree $file
fi
done
popd
#pwd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment