【发布时间】:2019-07-05 13:28:07
【问题描述】:
第一次提问。我正在做一个关于 git 的教程,涵盖了服务器上的代码已更新且本地代码已独立更新的实例,因此存在冲突。
在视频中,讲师执行 git pull 并尝试获取文件。对话框获取详细信息,然后说
Auto-merging hello.html
但我的,在那个阶段,说
error: Your local changes to the following files would be overwritten by merge:
hello.html
在解决冲突之前,我最终无法推送或拉取更改。我最终不得不这样做
git stash
git pull
git stash apply --index
我需要将配置应用到本地 git 以使其尝试自动合并吗?
为了清楚起见
$ git pull
error: Your local changes to the following files would be overwritten by merge:
hello.html
Please commit your changes or stash them before you merge.
Aborting
Updating 7ed9dbb..0525225
Erik@DESKTOP-TI7OP0E MINGW64 /e/gitrepo/webcourse (master)
$ git commit -m "save"
On branch master
Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
(use "git pull" to update your local branch)
Changes not staged for commit:
modified: hello.html
no changes added to commit
【问题讨论】:
-
听起来您需要提交一些更改?
-
自动合并尽力而为,但它也努力不破坏您的本地更改。在这里,它告诉您它不能自动合并,因为这会撤消您的一些工作。提交您的更改,然后合并,此时您将有机会解决冲突。
-
我遇到的问题是,当我进行拉取时,它不会尝试自动合并。它只是说我的本地更改将丢失并中止。在讲座中,它尝试了自动合并,然后他的本地文件显示了差异。然后他可以选择他想要的版本并进行更新。