[英]git pull on staging server failing because of local changes
On my staging server I have a cron job that does a git pull
every two minutes, most of the times everything works fine, but sometimes I notice that the changes that I pushed to the repo are not pulled, when I inspect the issue and run git pull
manually I get an error: 在我的登台服务器上,我有一个cron作业,每两分钟执行一次
git pull
,大多数情况下一切正常,但是有时我注意到,当我检查问题并运行时,没有推送到存储库的更改被撤消git pull
手动我得到一个错误:
error: Your local changes to the following files would be overwritten by merge:
{the file(s) that I had pushed to the repo}
Please, commit your changes or stash them before you can merge.
I don't understand how these changes are being considered "local changes". 我不明白这些更改如何被视为“本地更改”。 any help?
有什么帮助吗?
I mentioned before (" Cannot pull with rebase ") that git rebase
learned the --autostash
option (git 1.8.5+). 我之前提到过(“ 无法使用rebase拉动 ”),
git rebase
学习了--autostash
选项(git 1.8.5+)。
You could combine that with a reset --hard in order to make sure the end result of your scheduled git upll is always a clean state: 您可以将其与reset --hard结合使用,以确保计划的git upll的最终结果始终是干净状态:
git config rebase.autostash true
git pull -rebase
git reset --hard
That assumes you have no local commit or work in progress on the repo updated by your git pull
(or it would be erased by the reset --hard
) 假设您没有本地提交或正在进行由
git pull
更新的回购工作(否则将由reset --hard
删除)
The autostash
option ensure that the untracked state of the working tree (for whatever reason) is not blocking the git pull
. autostash
选项确保工作树的未跟踪状态(无论出于何种原因)不会阻止git pull
。
And the reset --hard
should make sure the working tree is clean. reset --hard
应该确保工作树是干净的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.