0

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.

awolfe76
  • 215
  • 5
  • 13

1 Answers1

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

Edward
  • 26
  • 1
  • Thanks that is very helpful. So when you say that I can use the hook, do you mean the post-commit hook on the bare repo? The push will actually do a commit? And then do I need to do more than just a commit to get the object hash created? Like this $ git hash-object -w test.txt. – awolfe76 Feb 01 '13 at 04:03
  • I'm just not sure how I can then read the file from the bare repo. Do I always have to make it an object? – awolfe76 Feb 01 '13 at 13:44