由于本地更改,临时服务器上的git pull失败
在我的暂存服务器上,我有一个cron作业,每两分钟执行一次由于本地更改,临时服务器上的git pull失败,git,version-control,Git,Version Control,在我的暂存服务器上,我有一个cron作业,每两分钟执行一次git pull,大多数时候一切正常,但有时我注意到我推送到repo的更改没有被拉取,当我检查问题并手动运行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 chan
git pull
,大多数时候一切正常,但有时我注意到我推送到repo的更改没有被拉取,当我检查问题并手动运行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.
我不明白这些变化是如何被视为“局部变化”的。有什么帮助吗?我在前面(“”)提到,git rebase
学习了--autostash
选项(git 1.8.5+)
您可以将其与重置结合起来,以确保计划的git upll的最终结果始终处于干净状态:
git config rebase.autostash true
git pull -rebase
git reset --hard
假设您没有本地提交或正在处理由您的git pull更新的回购协议
(或者它将被reset--hard
擦除)
autostash
选项确保工作树的未跟踪状态(无论出于何种原因)不会阻止git pull
而重设--hard应该确保工作树是干净的。似乎您无意中在服务器上编辑了一个文件。我建议首先使用
git diff
验证更改,然后如果您不想在服务器上进行更改,您可以执行git stash
这发生了多次,并且本地更改始终是我的最新提交。每次出现错误时,它都会引用某个特定的文件吗?还可以看一看