import subprocess
for line in subprocess.check_output('git status -s', shell=True, universal_newlines=True).splitlines():
if not line.startswith(' M '):
continue
filename = line[3:]
with open(filename) as fp:
first = fp.readline()
if first != '\n':
continue
contents = fp.read()
with open(filename, 'w') as fp:
fp.write(contents.lstrip())
Performed automatically using the following commands:
... and the following script: