How to reset files with only whitespace changes in git?

Member

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

How to reset files with only whitespace changes in git?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by orpha , 8 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.

Related Threads:

What does "unstaged changes after reset" mean in git?
How to unstage files with no changes in git?
How to reset to the main branch in git?
What does `git reset --hard origin` do?
How to stash changes in Git?
How to commit changes to the Git repository?