Maybe a bit of overkill for your problem, but I'm using ANT to build my website before deploying. With this ANT-building it is possible to remove, move, add or change certain files.
This way you can put the GIT tag (I always use tags before building/deploy) in a config file. See my other post on configuration files.
I use ANT to do roughly the following:
- make GIT create a copy in a separate folder
- strip all files that shouldn't go online
- make some changes to config files
- create a CHANGELOG file with all the commits in neat order, separated by the GIT Tags for better reading.
Then, all is safe to blindly upload the whole thing in one FTP run.
Steps to get your latest tag in a config file:
- create a config file in e.g. your root folder ("site.default.properties")
- put a revision attribute in there (SITE_REVISION_NUMBER=xxxx)
- make ANT work with GIT to get GIT info
This last thing can work like this in ANT build script:
<property name="GIT-src" location="/home/martin/deploy/build"/>
<exec executable="git"
failonerror="true"
outputproperty="tag.current"
dir="${GIT-src}">
<arg line="describe --tag"/>
</exec>
then you have a property ("tag.current") you can put in a config file and read it from PHP:
<propertyfile
file="${deploy}/site.default.properties"
comment="Site properties">
<entry key="SITE_REVISION_NUMBER" value="${tag.current}"/>
</propertyfile>