How to discover a file is changed in GIT during a push
Asked Answered
I

1

2

when I push something to my GIT repository, the post-receive hook is triggered and executes some scripts. Is it possible doing something before the execution these scripts if (and only if) a specific file is changed respect to the previous push (for example .sql file)?

Thanks

Randomize

Isoprene answered 20/11, 2011 at 9:7 Comment(0)
K
1

In the same post-receive hook as a first step or in a pre-receive or update hook, you can use

git diff-tree --name-status -rz

and pass in the new and old ref that are passed in to the hook ( either stdin or arguments) and get the files, check for modified - M - status in the output and do what you need.

Also see here for alternate ways: http://progit.org/book/ch7-4.html

Ker answered 20/11, 2011 at 9:24 Comment(1)
sorry forgot: how can I get the changed file (in this case the sql file) to execute it?Isoprene

© 2022 - 2024 — McMap. All rights reserved.