How does this pre-commit hook fix trailing whitespace?

前端 未结 3 1242
没有蜡笔的小新
没有蜡笔的小新 2021-01-21 08:06

What is going on in this pre-commit hook? I thought changing files would cause them to be restaged.

#!/bin/sh
#
# A git ho         


        
3条回答
  •  我在风中等你
    2021-01-21 08:25

    Except that this does not work. I've tried doing the following at the end of my pre-commit hooks:

    exec git diff-index --check --cached $against --
    

    but the changes made in those hooks still do not actually get committed (at least in git 1.7.3.4).

    If you actually want the changes to go in, you must explicitly

    git add "$file"
    

    for each file that you modified during the pre-commit phase.

提交回复
热议问题