更新时间:2023-12-05 14:48:04
You cannot just git checkout -f
, because that means repo1 is dumping its content on repo2 working tree:
# repo1 post-receive hook
GIT_WORK_TREE=/path/to/repo2 git checkout -f
What you need is for repo2
to pull repo1 content in order to update its (repo2
) content.
Plus, the fact that repo2
initiates the update means that other repo2 hooks will have a chance to be triggered in turn.
# repo1 post-receive hook
GIT_DIR=/path/to/repo2/.git
GIT_WORK_TREE=/path/to/repo2 git pull repo1