Skip to content

Instantly share code, notes, and snippets.

@santaklouse
Last active September 28, 2023 08:16
Show Gist options
  • Save santaklouse/977b91a441e20b1e4bf585d962cef932 to your computer and use it in GitHub Desktop.
Save santaklouse/977b91a441e20b1e4bf585d962cef932 to your computer and use it in GitHub Desktop.

Create patch

create raw binary git patch file for untracked files only (exclude: zip archives/files/ directory/*.patch files)

$ { for next in $( git ls-files --others --exclude-standard --exclude=*.zip --exclude=files/* -x '*.patch') ; do git --no-pager diff -p --ignore-space-change --ignore-cr-at-eol --raw --binary -b -w --no-index /dev/null $next; done; } > untracked.patch

Apply patch

show information about changes that will be applied

git apply --stat untracked.patch  

apply changes

git apply --binary --reject untracked.patch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment