Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undo line ending changes in Git

My question is similar to Git - unchange line endings in already committed file, though the accepted answer seems to be mostly musings, and not helpful in my situation.

I have several fairly large commits. Between my editor and my git configuration at the time, I committed many line ending changes

For example, I changed on line in a file, but my commit changes line endings for the thousands of other lines in the file.

I have not pushed the commits. How to I remove the line ending changes before I push?

I tried

git rebase [last_good_commit]

but it just said

current branch *** is up to date. 
like image 485
Paul Draper Avatar asked Jan 07 '14 17:01

Paul Draper


1 Answers

Simply force a rebase for the commits you haven’t pushed yet, and tell it to apply whitespace fixes to the patches:

git rebase --whitespace=fix -f <last_good_commit> 

Rebase internally works via applying patches, and conveniently git-apply supports fixing the whitespace with the --whitespace option.

like image 91
mockinterface Avatar answered Oct 21 '22 20:10

mockinterface