简体   繁体   中英

Can I setup Git to tell me each time a certain file(s) has been modified

Is it possible to set Git up in a way that it will tell me when a choice file(s) has been modified. I would like this to be setup similarly to a git hook, but I don't need to know when anything in the whole project has been changed only a choice file.

This is for a Java project that I am running in eclipse.

Edit I have been considering this and am wondering if it is possible to accomplish this without putting in a Git hook that all other developers will need to run. I realize that might not be possible, if it is not possible I will accept the more standard answer.

You can hook the whole directory (eg pre commit), and then filter to get just the file(s) you want.

my_files=$(git status --short | grep -E '^(A|M)' | awk '{ print $2 }' | grep -E 'WhateverPatternYouNeed\.php$')

for file in $my_files; do
  # Do something... 
done

Of course your "do-something" can make a curl call to text you, email, etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM