Maintain multiple simultaneously-accessible versions of website remotely using Git

后端 未结 2 388
长情又很酷
长情又很酷 2020-12-20 02:17

I want to set up Git so I can have various versions of the same website accessible simultaneously. For example, a \'Sandbox\' site, a \'Staging\' site and a \'Production\' s

相关标签:
2条回答
  • 2020-12-20 02:33

    This may not help your question regarding Git, but I would not prefer this kind of workflow in web development, when there is a way which is, in my opinion, something that requires a little more work, but in exchange is a lot more flexible and reliable.

    I would just mark a bare, public repository where all commits go by push and fetch (like what you are using that has the hooks), but without any hooks. I would then have 2 project directories on the remote server: one for dev and one for master; both using cloned, non-bare git repositories (each having a .git folder). So you would have 1 bare repository on your web server (or it can be on any server) and 2 non-bare repositories.

    In this case, you can push all you want locally, the working directory in your web project directories will only change when you decide to pull. This has the added benefit to being able to make quick changes directly on the remote server's project directory in case an error relating to the environment of the project comes out, which you can commit the fix and push it back easily.

    And with multiple remote project directories (and urls), you can have multiple project states simultaneously on the same server.

    0 讨论(0)
  • 2020-12-20 02:41

    Checkouts in the post-update hook will work, but you might want to define also GIT_DIR

    See:

    • "using git to deploy my node.js app to my production server"
    • "Git checkout in post-receive hook: “Not a git repository '.'”"

    That will make sure the git commands knows where the git repo is.

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