17

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. 
Community
  • 1
  • 1
Paul Draper
  • 71,663
  • 43
  • 186
  • 262

1 Answers1

15

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.

mockinterface
  • 13,787
  • 5
  • 26
  • 46