0

Basically, I want to write a pre-commit hook to check if the about-to-be-committed changes (re)move a file without using git rm / git mv.

I don't know how to approach this.

musicmatze
  • 4,124
  • 7
  • 33
  • 48
  • What do you mean by "without using `git rm`/`git mv` - do you mean that you do not want to use either of these in the pre-commit hook? – Jean Hominal Sep 23 '14 at 08:52
  • I want to check if a file was removed with `rm` or moved with `mv` - so it was _not_ removed using `git rm` or moved using `git mv`. Moving with `mv` causes one to become author of the complete file, which is clumsy when running `git blame` for example. – musicmatze Sep 23 '14 at 08:56
  • Is the question about how to write a git pre-commit hook, or is it about programmatically checking the "about-to-be-committed" changes? Also, what do you intend to do once you find such a file? – Jean Hominal Sep 23 '14 at 13:17

1 Answers1

0

You can use git commit --dry-run and inspect the output.

Claudio
  • 10,614
  • 4
  • 31
  • 71