0

I have a pre-commit hook which modifies some files before they are committed; however when the hook runs, the files that it modifies do not get committed! How can I have the files included? I need this to work both for staged commits and unstaged "commit all modified files" commits, so I don't think staging the modified file will work here because that would exclude the original files in the latter case (since they are not staged).

Here's a simple reproduction case:

#!C:/Program\ Files/Git/usr/bin/sh.exe echo "Test file" > testfile.txt 

If I change a file and commit, the testfile.txt never gets committed; if I change a file, stage it, and commit, the same thing happens - testfile.txt is sitting there as a pending change.

2
  • 1
    Append git add testfile.txt to the hook. Commented Jul 19, 2019 at 14:10
  • stackoverflow.com/… Commented Jul 19, 2019 at 15:31

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.