Skip to content

Instantly share code, notes, and snippets.

@sandordargo
Last active July 1, 2019 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sandordargo/ce3a55be6bd794be1826391ebe95718b to your computer and use it in GitHub Desktop.
Save sandordargo/ce3a55be6bd794be1826391ebe95718b to your computer and use it in GitHub Desktop.
git diff & add combined
[alias]
da = "! addprev() { while true; do \
read -p \"Do you wish to add this file? ([Y]es, [N]o, [P]atch)\" yn ; \
case $yn in \
[Yy]* ) git add $1; break;; \
[Pp]* ) git add -p $1; break;; \
[Nn]* ) exit;; \
* ) echo "Please answer yes, no or patch.";; \
esac \
done } ; \
gotoUsedDirectory() { \
if [ -n \"${GIT_PREFIX}\" ]; then \
cd ${GIT_PREFIX} ; \
fi \
} ; \
echo \"$1\" ; \
gotoUsedDirectory && git diff $1 && addprev $1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment