Last active
May 27, 2025 19:40
-
-
Save hello-josh/dbabb56e1a01ac293b83154a6f4a208e to your computer and use it in GitHub Desktop.
Revisions
-
hello-josh revised this gist
Aug 27, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -24,6 +24,6 @@ How to remove whitespace-only changes from a PR git diff --cached 7) Commit your work! git commit -
hello-josh revised this gist
Aug 27, 2021 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,28 +2,28 @@ How to remove whitespace-only changes from a PR 1) Create a new local branch that will contain your changes without the whitespace git checkout -b tmp-branch 2) Merge the changes that contain whitespace into your current branch WITHOUT committing the changes git merge <the branch with whitespace> --no-commit 3) Create a diff that ignores whitespace and apply it to your branch. This creates a diff in unified format, ignoring whitespace, and not colorizing the output. Then using git to apply (like applying a patch) to the current directory. git diff -U0 -w --no-color | git apply --cached --ignore-whitespace --unidiff-zero - 4) Remove any remaining unstaged changes. The unstaged changes are the whitespace-only changes git checkout . 5) Add any new files back to the staged changes since the diff/apply method ignores net-new files. git add . 6) Verify your work git diff --cached 7) Commit you work! git commit -
hello-josh created this gist
Aug 27, 2021 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ How to remove whitespace-only changes from a PR 1) Create a new local branch that will contain your changes without the whitespace git checkout -b tmp-branch 2) Merge the changes that contain whitespace into your current branch WITHOUT committing the changes git merge <the branch with whitespace> --no-commit 3) Create a diff that ignores whitespace and apply it to your branch. This creates a diff in unified format, ignoring whitespace, and not colorizing the output. Then using git to apply (like applying a patch) to the current directory. git diff -U0 -w --no-color | git apply --cached --ignore-whitespace --unidiff-zero - 4) Remove any remaining unstaged changes. The unstaged changes are the whitespace-only changes git checkout . 5) Add any new files back to the staged changes since the diff/apply method ignores net-new files. git add . 6) Verify your work git diff --cached 7) Commit you work! git commit