Skip to content

Instantly share code, notes, and snippets.

@musicm122
Last active December 11, 2015 14:09
Show Gist options
  • Save musicm122/4612358 to your computer and use it in GitHub Desktop.
Save musicm122/4612358 to your computer and use it in GitHub Desktop.
Preforms a git checkout -- file on every file in current directory
#!/bin/bash
#Author: Terrance Smith
#musicm122.blogspot.com
#Optional Argument = n : no prompt
#currently will take a while on a large number of files
function print_files
{
for file in *
do echo $file
done
}
function git_checkout_dir
{
for file in *
do git checkout -- $file
done
}
if [[ $# -gt 0 ]]; then
if [[ "n" == "$1" ]]; then
git_checkout_dir
print_files
else
echo -e "operation cancelled"
exit
fi
else
echo -e "The following command will preform a 'git checkout -- file' on every file in the current directory and can take a fair amout of time\nDo you wish to continue? y/n"
read confirmation
if [[ "y" == "$confirmation" ]]; then
#$(git_checkout_files)
echo "test mode"
echo -e "checkout complete on the following files"
print_files
else
echo -e "operation cancelled"
exit
fi
fi
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment