是什么原因导致这个 git 警告?
最近,每当我执行 git Push 时,我都会得到这样的交换:
owner-pc ~/dev/project $ git push
Counting objects: 15, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (8/8), 3.15 KiB, done.
Total 8 (delta 6), reused 0 (delta 0)
remote: Pulling changes into edge...
remote: From /var/git/project
remote: * branch master -> FETCH_HEAD
remote: error: Your local changes to 'config/development.php' would be overwritten by merge. Aborting.
remote: Please, commit your changes or stash them before you can merge.
remote: Updating 1984db9..d584535
remote: Changes have been pulled and applied to edge.
To ssh://dev.trueaction.com/var/git/project
a3a085e..8ec5b07 styleguide -> styleguide
……但是推送显然完成时没有错误,并且一切正常。 config/development.php
没有任何本地更改,而且已经有一段时间没有更改了。我在提交时没有收到任何错误或警告,仅在推送时收到,而在拉取时则没有。
导致错误的原因是什么? (它的行为类似于警告,但表示这是错误,所以我将使用该术语。)
Lately whenever I do a git push I get an exchange like this:
owner-pc ~/dev/project $ git push
Counting objects: 15, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (8/8), 3.15 KiB, done.
Total 8 (delta 6), reused 0 (delta 0)
remote: Pulling changes into edge...
remote: From /var/git/project
remote: * branch master -> FETCH_HEAD
remote: error: Your local changes to 'config/development.php' would be overwritten by merge. Aborting.
remote: Please, commit your changes or stash them before you can merge.
remote: Updating 1984db9..d584535
remote: Changes have been pulled and applied to edge.
To ssh://dev.trueaction.com/var/git/project
a3a085e..8ec5b07 styleguide -> styleguide
…but the push apparently completes without error, and everything works fine. There are no local changes to config/development.php
, nor have their been for some time. I don't get any errors or warnings on commit, only on push, and not on pull.
What causes the error? (It behaves like a warning, but says it's an error, so I'm going with that term.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
“错误”发生在 post(-receive) 钩子中(由
remote:
前缀证明),其中钩子正在拉取您推送到其他某个存储库中的代码,并且该存储库有一些本地修改这导致了错误。由于接收后钩子不会影响推送的结果(因为它们发生在推送之后),所以推送本身进展顺利,但由于本地更改,钩子作为接收后的一部分尝试的拉取失败了。
找到拉取发生的位置(在 /var/git/project/hooks/ 中找到一个 post-receive 或其他一些处于活动状态的钩子,看看它在做什么)并删除那里的本地修改。
The "error" is happening in a post(-receive) hook ( as evidenced by the
remote:
prefix) where the hook is pulling the code you pushed into some other repo and that repo has some local modifications that is causing the error.Since post-receive hooks do no affect the outcome of the push ( since they happen after the push ), the push itself has gone fine, but the pull that the hook attempted as part of the post-receive has failed due to the local changes.
Find where the pull is happening ( in /var/git/project/hooks/ find a post-receive or some other hook that is active and see what it is doing ) and remove the local modifications there.
从你的输出来看 - 你正在推送到一个非裸仓库,并且有人在远程编辑了 config/development.php 。这就是生成您所看到的交换的原因。
Judging from your output - you're pushing to a non-bare repo, and someone edited config/development.php on the remote. This is what generates the exchange you're seeing.