Git push to live server

后端 未结 6 592
北恋
北恋 2020-12-12 11:11

We have a website that has all its PHP/HTML/JS/CSS/etc files stored in a Git repository.

We currently have 3 types of computers (or use cases) for the repository.

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-12 12:02

    I had the same query and not satisfied with the currently top-voted answer here, ended up following git-website-howto which outlines the process fairly well and is IMO a much cleaner and quicker approach.

    TL;DR, git init --bare to create a fresh repo on your web server where you will push your changes from your dev machine. When the web repo receives your changes, it fires the post-receive hook which then copies the files to your web root.

    I like this approach because the post-receive hook does the work on your server so your local machine can push much faster and free itself up. This also makes it very easy to setup remote tracking for a particular branch. So you could have a branch called production to update your web server, while your master continues to be for development and link to your git repo elsewhere.

    Note: you'll need run git config receive.denycurrentbranch ignore on your web server repo to suppress a warning on your local dev box when pushing.

提交回复
热议问题