create_patch.sh (573B)
1 #!/bin/sh 2 # 3 # create_patch.sh - Creates an enhancement patch based on the current Git changes 4 # 5 6 if [ "$#" -ne 1 ] 7 then 8 echo "Usage: $0 patch_file" 9 echo ' Creates a patch file based on the changes made to the current directory' 10 exit 1 11 fi 12 13 # Make sure this is a git repository 14 if [ ! -d .git ] 15 then 16 echo 'Error: The current directory is not a Git repository.' 17 exit 1 18 fi 19 20 # 'git diff' is stupid and doesn't show new untracked files, so we must add them first. 21 git add . 22 # Generate the patch. 23 git diff -p --staged > "$1" 24 # Undo the 'git add'. 25 git reset