This behaviour is part of git commit
‘s default ‘clean-up’ behaviour. If you want to keep lines starting with #
you can use an alternative clean-up mode.
E.g.
git commit --cleanup=whitespace
If you do this you have to be careful to remove all #
lines that you don’t want to appear in the commit.