有人建议我在远程服务器上设置
foo.com/~/bar.com # live webpage content
foo.com/~/bar.com.git # a bare repo
所以,从我的本地机器上,我可以做一个
git push
它将推送到foo.com/~/bar.com.git
远程机器上(完整路径是ssh://peter@www.foo.com/~/bar.com.git
如何添加一个钩子,以便在推送之后,远程服务器会cd ~/bar.com
并做一个git pull
,以便更新所有内容(与本地机器相同)?(不需要git update
像 Mercurial 那样运行?)
(这与Cannot git clone a folder on a server and then edit and git push有关? 现在我可以ssh到foo.com
并cd ~/bar.com
在那里等待,并在本地机器git pull
之后git push
随时执行,但拥有它会很好自动完成)
更新:如果您知道具体细节以及如何做,请仅发布答案。如果你用谷歌搜索并在这里发布第一个或第二个谷歌结果,它不会有帮助。
更新 2:我去~/bar.com.git/hooks
并添加了一个post-receive
包含内容的新文件:
#!/bin/bash
cd ~/bar.com
git pull ../bar.com.git master
还有chmod 755 post-receive
,如果我在本地机器上编辑一个文件,然后git com -m "ok"
,git push
它不会使更改进入远程机器的文件夹~/bar.com