How to reset files with only whitespace changes in git?

Member

by lizzie , in category: Third Party Scripts , 3 months ago

How to reset files with only whitespace changes in git?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by orpha , 3 months ago

@lizzie 

You can reset files with only whitespace changes in git by using the following command:

1
git reset --ignore-whitespace path/to/file


This command will reset the specified file and ignore any whitespace changes that may have been made to it. You can also use the --ignore-all-space option to reset all files in the repository with only whitespace changes.


If you want to reset all files with only whitespace changes in the repository, you can use the following command:

1
git diff --name-only -w | xargs git checkout


This command will list all files with whitespace changes and reset them to the last commit in the repository.