Last active
August 29, 2015 14:26
-
-
Save jfairbank/e4ce5a0f1061d97afad5 to your computer and use it in GitHub Desktop.
git-diff-add
This file contains hidden or 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
#!/bin/bash | |
# git diff a file and then be presented with the option to stage | |
# the file with "y" or stage a portion with patch via "p" | |
filepath="${1-.}" | |
git diff "$filepath" | |
[[ $? -ne 0 ]] && exit | |
printf "\nOk to stage? [y/p/N]: " | |
read stage | |
if [[ "$stage" == "y" || "$stage" == "Y" ]]; then | |
git add "$filepath" | |
elif [[ "$stage" == "p" || "$stage" == "P" ]]; then | |
git add -p "$filepath" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment