Using git to publish to a website

后端 未结 3 2035
野性不改
野性不改 2020-12-14 12:04

I used this guide to use git to autopublish my changes on my website when I push to my remote origin git repository:

http://www.lwp.ca/james/2010/03/using-git-to-man

相关标签:
3条回答
  • 2020-12-14 12:32

    Not a lot to go off of here, but I can report that I successfully use a similar method to this.

    For my purposes, I call my bare server repository the "Hub" and my web-facing repository the "Prime". Make sure that you have properly initialized a git repository in your server htdocs directory (Prime) and have either pushed the changes to the bare repository (Hub) or pulled them in.

    This is the post-update hook I use, which is in my Hub repository's hooks directory:

    #!/bin/sh
    
    echo
    echo "*** Pulling changes into Prime"
    echo
    
    cd /path/to/htdocs/ || exit
    unset GIT_DIR
    git pull hub master
    
    exec git-update-server-info
    

    Make sure this is executable! If in doubt, just edit the post-update.sample file and remove the .sample extension when done. The echoed text gives nice feedback that the copying is actually taking place. If you don't see that text, then it's not pulling the changes. And if you're not going to call your remote repository "hub", replace it with "origin" or whatever you decide to use.

    As a precaution so that my Prime and local repositories don't get too out of whack, I have this as my Prime post-commit hook:

    #!/bin/sh
    
    echo
    echo "*** Pushing changes to Hub"
    echo
    
    git push hub
    

    Then I can just pull the changes from Hub into my local repository.

    0 讨论(0)
  • 2020-12-14 12:41

    You can find a better alternative at http://toroid.org/ams/git-website-howto that only uses one git repository, and allows all metadata and previous history to remain outside of the DocumentRoot.

    The guide you used and the one I linked referrer to another article both are based on, but the one I linked seems to be the preferred one to direct new users to in the #git IRC channel.

    0 讨论(0)
  • 2020-12-14 12:44

    You might start by getting post-update to echo some debugging output. Both standard output and standard error output are forwarded to git send-pack on the other end, so you can simply echo messages and you will see these on the client that you did git push. I assume you followed the guide to the word, made the post-update script executable, cloned the repo to the web folder etc.

    0 讨论(0)
提交回复
热议问题