Created
June 23, 2020 18:29
-
-
Save roma-glushko/6bb137790a7e6e24e66cbdda6bd38e2b to your computer and use it in GitHub Desktop.
A simple interface around git commands that simplifies patch creation
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
#!/bin/bash | |
command=$1 | |
path=$2 | |
currentDir="`pwd`" | |
# display usage | |
# run commands one after the other using | |
[ $# -eq 0 ] && { echo -e "Usage: $0 command [path]"; exit 1; } | |
case $command in | |
"init"|"i") | |
echo "• Saving the current state of ${path} as initial.."; | |
(cd $path && rm -rf .git); | |
( cd $path && git init && git add . && git commit -m "Patchy: Initial state of the directory" );; | |
"create"|"c"|"cr") | |
patchFile="${currentDir}/mypatch.patch" | |
echo "• Creating a new patch (${patchFile})"; | |
( cd $path && git diff --binary > "${patchFile}" );; | |
"reset"|"r") | |
echo "• Reset all changes prior to the initial state.."; | |
( cd $path && git reset --hard );; | |
"clean"|"cl") | |
echo "• Cleaning git repository under ${path}.."; | |
( cd $path && rm -rf .git );; | |
*) | |
echo "Unknown command." | |
exit 2;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment