我有一台安装了Git的Linux服务器。我正在开发一个Web应用程序,我想在网站路径(/ var/www/apps/myapp)上的服务器上创建一个git存储库,然后将我的本地存储库更改推送到它。使用非裸Git存储库更新服务器文件
当我创建了服务器非纯仓库,推动了变化,我得到这个错误:
Refusing to update checked out branch: refs/heads/master. By default, updating the current branch in a non-bare repository is denied, because it will make the index and work tree inconsistent with what you pushed, and will require 'git reset --hard' to match the work tree to HEAD. etc.
它建议使用裸存储库。我可以成功地做到这一点,但我的问题是,我希望我的服务器在推送更改时自动更新Web应用程序文件夹。据我了解,当我使用裸存储库时,我必须再次在服务器上克隆裸存储库以获取真实文件。这样我有3个存储库。两个在服务器端(其中一个是裸露的),另一个在本地。
我只想要一个只读存储库,我可以推送我的更改并更新服务器端的Web应用程序文件夹内容。
解决方案是什么?
数据丢失不危险吗? –
还有一些观点:1)我没有post-receive.sample,但有update-update后的样例。 2)'pwd'是什么意思? –
我使用'git push -f origin master',但结果相同。 –