Created
February 12, 2017 21:47
-
-
Save egladman/c377f7822326dfefffe0674002cf6388 to your computer and use it in GitHub Desktop.
Prevent accidental changes from being committed to git
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Append the following snippet to your bash.rc | |
#Whenever "git add foo" is ran "git diff" will first run | |
#and require user confirmation before changes are added. | |
git() { | |
if [[ $1 == "add" ]]; then | |
command git diff | |
read -p "Are you sure? " -n 1 -r | |
echo | |
if [[ $REPLY =~ ^[Yy]$ ]]; then | |
command git add "${@:(2)}" | |
fi | |
else | |
command git "$@" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment