GIT post-receive checkout without root folder

后端 未结 1 905
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-29 11:41

I\'m new to git, trying to figure out how to have a website updated with each push by doing a checkout to the web root. I have searched stackoverflow and only found topics a

相关标签:
1条回答
  • 2020-11-29 12:38

    If:

    • /path/to/website/httpdocs is a git repo
    • /path/to/project_root is a git repo (i.e. there is a .git directory)

    Then you can use in your post-receive hook:

    git --git-dir=/path/to/project_root/.git --work-tree=/path/to/website/httpdocs checkout -f
    

    But if you are pushing to project_root, it is rather a bare repo, in which case, its root directory should be called /project_root.git, and the post-receive hook would look like:

    git --git-dir=/path/to/project_root.git --work-tree=/path/to/website/httpdocs checkout -f
    

    In any case, project_root must be the root of a git repo.


    The OP choppingblock comments:

    it seems that the problem is caused by the eclipse git plugin (EGit), which automatically creates a root folder with the name of the project.
    I now worked around it by changing the path to the webroot from /path/to/website/httpdocs to /path/to/website/httpdocs/project_root.

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