How to fix Trailing whitespace during Git commit

Git uses hooks to fire certain actions at certain times. The “post-commit” hook fires … If you don’t understand what the hooks do after reading the hook file name itself turn off your computer and go to sleep.

You can look in there it’s in your .git/hooks folder in your repository.

There are times where this is useful probably, but I can’t think of a single one so I’m just going to tell you how to get rid of it because it really is a pain in the ass.

Fix the Trailing Whitespace during Git commit message

[bryan@crainbandy sites]# mkdir testdir
[bryan@crainbandy sites]# cd testdir/
[bryan@crainbandy testdir]# git init
Initialized empty Git repository in .git/
[bryan@crainbandy testdir]# cd .git/
[bryan@crainbandy .git]# ls
branches  config  description  HEAD  hooks  info  objects  refs
[bryan@crainbandy .git]# cd hooks
[bryan@crainbandy hooks]# ls
applypatch-msg  commit-msg  post-commit  post-receive
post-updatepre-applypatch  pre-commit  pre-rebase  update
[bryan@crainbandy hooks]# rm -rf *
[root@crainbandy hooks]# ls
[root@crainbandy hooks]#

You’ll probably read all kinds of crap about this but the fix is to simply remove all of the files in your .git/hooks directory.

Happy rm -rf’ng.
Bryan

Related reading

  • No Related Post

2 Responses to “How to fix Trailing whitespace during Git commit”

  1. sriram  on August 4th, 2010

    thanks for the tip buddy.. it was painful before this

  2. chuck  on March 1st, 2011

    if you’re going to ignore errors you should use `git commit –no-verify`. this will skip the pre-commit checks but obviously keeps the scripts intact, so you can continue to use them at a later date.


Leave a Reply