Having fun with GIT

It was just yesterday morning that a light came on in my head and I understood just what the index file was for in git. It seemed to strip away the fear that I was always not quite sure what I was doing, and allowed my to experiment a bit to see what I could do.

Well I have been playing with the post-update hook. As a result, I can now

It was just yesterday morning that a light came on in my head and I understood just what the index file was for in git. It seemed to strip away the fear that I was always not quite sure what I was doing, and allowed my to experiment a bit to see what I could do.

Well I have been playing with the post-update hook. As a result, I can now

  • push a update from my working machine into a repository embedded within this web site. The arrival of a new update triggers it to check out this new version so that the web server automatically gets the new version to work with.
  • push to any of the public repositories on this machine a new tag (ie release) and it automatically makes a tar ball of the whole code and puts it into the downloads directory

I haven’t (yet) got it automatically deploying new versions of my applications – but I am sure it will not be long:-)

Author: Alan

I am Alan Chandler.

One thought on “Having fun with GIT”

  1. Although this approach works fine, it does mean that your web pages needs a git repository embedded within it.  A better approach, and one I use now is to use rsync to copy (and synchorise) the files at the remote end.

    Here is an example, which detects a git merge, or a commit in one of two branches (site and test) which then rsyncs via ssh (to site mb) into the web locations for the production and test sites respectively.

    #!/bin/sh
    #
    #  Output a version file that we can include at the bottom of the page
    
    branch=$(git branch | sed  -n s/^\*\ //p)
    
    cd "$(git rev-parse --show-cdup)"
    if [ "$branch" == "site" ]; then
        git clean -f
        rsync -axq --delete --exclude=scripts/calendar --exclude=htaccess --exclude=.git --exclude=test ./ mb:public_html/static/
    fi
    
    if [ "$branch" == "test" ]; then
        git clean -f
        rsync -axq --delete --exclude=scripts/calendar --exclude=htaccess --exclude=.git  ./ mb:public_html/static/test/static/
    fi
    

Leave a Reply

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