When I do
git diff -w file_name
I see only added lines but when I remove -w
I see lots of removed and re-added lines too.
I want to change the file so that I will show only the changes that are not ignored by -w
option.
Is there a command for that?
jupp0r was on the right track. First, cd
to the root of your repository. Then:
git commit -a -m 'Backup commit.'
git branch pre-patch
git reset --hard HEAD~
git diff --patch -w HEAD pre-patch > patch.diff
git apply patch.diff
I'm not sure whether this will work for binary changes. If not, you can commit those separately beforehand. If this process fails, your code is in the pre-patch
branch.
What this does:
Note: If you've already committed the change and want to modify it, just omit the first step.
You can do
git diff --no-color > stage.diff && git apply -R stage.diff && git apply --whitespace=fix stage.diff && rm -f stage.diff
If you haven't committed any changes yet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With