Can a Git hook automatically add files to the commit?

前端 未结 10 1599
礼貌的吻别
礼貌的吻别 2020-11-28 05:08

I\'d like to add an automatically generated file to the same commit using a pre- or post-commit hook in Git, dependent on the files that were modified in that commit. How w

10条回答
  •  佛祖请我去吃肉
    2020-11-28 05:26

    I was facing same problem in pre-commit hook also. I was modifying one file and committing but it was taking previous file not updated file so by adding git command(as below) in pre-commit hook, it solved.

    git add $file
    

    note: $file is your file to be added.

    Thanks,

提交回复
热议问题