Reputation: 67
I've set up a remote server that I want to push git commits to. I've set it up with git init --bare
based on advice, but noticed it doesn't have the files there (working tree) after content is pushed there. AKA. if I have a file called something.txt
and add and commit it to a local repo, then push to the remote repo, it will record my commit but I can't actually see something.txt
on the remote filesystem.
The problem is that I actually want to manipulate the file remotely via a hook. AKA. once I push to any branch, an "update" hook will read a file in the repo and send it to another program.
At the moment, I can print the file list remotely via git ls-tree --full-tree -r HEAD
but I'm not yet sure how to view individual files or if I should even be doing it this way (doesn't seem like it's designed this way).
If I create the remote repo without --bare
, then I get an error when trying to push due to lack of working tree.
Upvotes: 0
Views: 541
Reputation: 6864
Of course you can also print the file with command line tools, but is that really what you want? You can simply create a local checkout (git clone $path-to-bare-repository $somewhere
).
If you really only care about that one file, have a look at git cat-file
, e.g.
git cat-file -p $ID_FROM_LS_TREE
As a one-liner:
git cat-file -p $(git ls-tree --full-tree -r HEAD | grep something.txt | awk '{print $3}')
Upvotes: 1