Using PHP to check and read a remote GIT file


I have been strugeling a bit with this issue during my build of a CI-system. I would like the user to select a git repostirory and branch and let the user install it, however, some settings might need to be set and wanted to read the ANT files “” and “” and show them in the client.

While reading the files, I didn’t want to checkout full projects to do so… so I had do digg around a bit. In the end my colleuge found this page:

So, here it goes, this is the code I use to check if there is a file available on the git repo, and what its content is.

Download the files here: PHPGit

It uses the git archive command.


There is a slight bug in it when using it as CLI, it prints the strdout. I haven’t fixed that yet.



Paul Peelen

Posted in Development, PHP Tagged with: , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *