不能用git推动以下教程

时间:2013-07-18 19:01:10

标签: git error-handling ssh zend-framework2 push

我遵循了本教程

http://danbarber.me/using-git-for-deployment

我做了一切,跟着它去喝茶。

我在我的本地计算机上,我对一个文件进行了更改,然后执行

git commit -a -m "test"

然后:

git push

然后询问我的服务器密码 所以我输入,我得到这个错误:

stdin: is not a tty
Counting objects: 13, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (7/7), 504 bytes, done.
Total 7 (delta 4), reused 0 (delta 0)
remote: 
remote: **** Pulling changes into live
remote: 
remote: From /var/git/agriTech
remote:  * branch            master     -> FETCH_HEAD
remote: error: Your local changes to 'module/Application/view/layout/layout.phtml' would be overwritten by merge.  Aborting.
remote: Please, commit your changes or stash them before you can merge.
remote: Updating 5a53563..7236cb6
To root@217.199.160.153:/var/git/agriTech.git
   5b4fafd..7236cb6  master -> master

1 个答案:

答案 0 :(得分:1)

我已经快速阅读了教程。

在服务器上,您在存储库/var/www/myproject中进行了本地修改(从教程约定中命名)。 永远不应该直接更新此存储库,否则它可能包含未经修改的修改,这不是您想要的。

错误原因:当您执行git push时,/var/git/myproject.git尝试更新/var/www/myproject,但由于它有本地修改,更新失败。

解决方案:

  • 进入服务器上的/var/www/myproject并运行git reset --hard HEAD。这将删除所有本地修改。
  • 现在您可以从本地计算机重试git push,一切都应该没问题。

为避免将来出现此问题,您可以在git reset --hard HEAD文件的unset GIT_DIR行后添加/var/git/myproject.git/hooks/post-update