在远程工作树上运行git命令(GIT_WORK_TREE = / path) [英] Run git commands on remote working tree (GIT_WORK_TREE=/path)
问题描述
GIT_WORK_TREE = / path / to / code git checkout -f
将代码推送到例如web服务器时可以很好地工作。我可以处理代码,当我完成时,更新Web服务器是一个简单的 git push live master
。
然而,我不知道如何回滚到例如特定的标签。通常可以用
git checkout TAG
来完成,但是当我尝试签出一个标签时(例如 GIT_WORK_TREE = / path / to / code git checkout - f标签
),git响应: 错误:pathspec'TAG'不匹配任何文件s)已知git
关于如何在远程工作树上签出标签的任何想法?
要检出远程端的标记,您需要先推送它:
git push --tags
使用GitHub时,如何在添加现有回购时推送所有分支?,甚至 git push --all
不会推动您的代码,只有 refs / heads /
中的所有代码。
I have a bare git repo set up which runs a post-update hook as follows:
GIT_WORK_TREE=/path/to/code git checkout -f
This works well when pushing code to, for example, a webserver. I can work on code, and when I'm finished, updating the webserver is a simple git push live master
away.
However, I don't know how to rollback to, for example, a specific tag. Usually that can be done with git checkout TAG
, but when I attempt to checkout a tag (e.g. GIT_WORK_TREE=/path/to/code git checkout -f TAG
), git responds:
error: pathspec 'TAG' did not match any file(s) known to git
Any ideas on how to checkout a tag on a remote working tree?
To checkout a tag on the remote side, you need to push it first:
git push --tags
As mentioned in "With GitHub how do I push all branches when adding an existing repo?", even git push --all
wouldn't push your tags, only all refs under refs/heads/
.
这篇关于在远程工作树上运行git命令(GIT_WORK_TREE = / path)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!