【发布时间】:2020-11-18 22:20:22
【问题描述】:
我是一个相对较新的开发人员。我最近制作了一个应用程序并使用 Heroku 进行了部署。它有一些错误,所以我修复了它们。昨天我在终端输入了常用命令;即git add .、git commit -m "Fixed some bugs" 和git push heroku master。当我输入最后一个命令时,它给出了一个错误提示
Error: failed to push some refs to '<someUr>l'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
我搜索了这个错误,发现这个问题here是类似的。所以我做了答案所说的; git pull 和 git pull heroku master。我会以某种顺序执行这五个命令几次(抱歉问题不清楚,这发生在昨天)。然后当我曾经git push heroku master 时,它没有给出任何错误。所以我前往我的网站,它给了我一个应用程序错误。当我回去检查我的文件时,我发现它们已经被修改了。
不知何故,>>>>>>>HEAD 和几个等号以及另一个看起来像哈希的奇怪组合都在文件周围。除此之外,它似乎添加了一些我之前删除的代码。
这是一场灾难。最后,我在终端输入git diff,修改了200行代码到之前的状态,在终端检查差异。
现在,在度过了一段美好的时光之后,我已经成功部署了它。我想知道是什么原因造成的,如果再次发生,如何解决。提前致谢。
【问题讨论】:
-
@Safwan 尝试运行此
git pull heroku master --allow-unrelated-histories。此命令将显示/添加一些您需要解决并再次提交的未合并冲突。