Last active
March 6, 2024 16:34
-
-
Save GrayedFox/a191e201620bb4adce226dc11b947ae2 to your computer and use it in GitHub Desktop.
Improved local patch management using named patch files, use carefully
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
#!/usr/bin/env bash | |
if [ $# -eq 1 ] ; then | |
NAME=$1 | |
else | |
echo "Please pass exactly one argument, which is the name of the patch file" | |
exit 1 | |
fi | |
git add . | |
# if previous patch file with the same name exists untrack it | |
if [ -f "$NAME.patch" ] ; then | |
git rm --cached $NAME.patch | |
fi | |
# warning: this will diff all changes into a file called NAME.patch and do a hard reset of the current branch | |
git diff --staged > $NAME.patch | |
git reset --hard $HEAD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
add safety check to remove previous patch file if it exists