问题
I have a scenario where I have a repo where users access the files directly, they don't know git exists, and make changes to what are essentially text files.
I have that repo cloned. So when a commit is made, the changes are pushed to the cloned repo using the post-commit hook.
Now, I have the cloned repo as a bare repo. But, what I would like to do at this point is have a script run each time a push is made. That script would read the content of the file(s) that were just pushed. Is that treated as a commit? Can I again use the post-commit hook?
Can that be done on a bare repo? Since there is no working directory? I'm don't see how I could "read" the file if the repo is bare.
回答1:
Yes, you can use the hook. However, you must use lower level git command to retrieve the commit tree and files from a bare repo. E.g. http://git-scm.com/book/ch9-2.html
来源:https://stackoverflow.com/questions/14639299/git-repo-auto-commit-and-push