如何忽略Git pull上的以下错误消息?

您对以下文件的本地更改将被合并覆盖

如果我想覆盖它们怎么办?

我试过像git pull-f这样的方法,但没有任何效果。

要明确的是,我只想覆盖特定的更改,而不是所有更改。


当前回答

在拉取之前,您必须提交所有尚未提交的文件,这样您就不会从AS收到该消息。

其他回答

对我来说,这是有效的:-

首先,我清理了所有未跟踪的文件,运行->gitclean-f。数字拉力

我是git新手,不确定我的解决方案是否是个好主意。

我测试了所有答案,但没有一个对我有用!

但我找到了另一个解决方案:

1. Backup both of local and repository versions of the file.
2. Delete the file from repository.
3. git add .
4. git commit
5. git push

希望这有帮助。

这里有太多的答案,我不想再添加一个,但以上所有的答案都比它们需要的要笨拙。我必须一直这样做,因为Git似乎变得困惑,并表示我修改了未更改的文件(无法恢复,因为它们没有更改,但我无法拉动,因为它们应该已更改)。到目前为止,我发现最简单、最快的是:

git stash
git stash drop
git pull

注意:本地更改将丢失

有时,这些都不起作用。令人恼火的是,由于LF的事情,我认为,将工作的是删除文件,然后拉。我并不建议使用此解决方案,但如果文件不存在,git不会毫无用处地通知您,您的更改(甚至可能不是更改)将被覆盖,并允许您继续。

使用风险自负。

如果使用git lfs并且文件指针被实际文件覆盖,也会出现此消息。

然后使用:

git stash
git lfs migrate import
git pull

我案子的全部结果

λ git stash
Saved working directory and index state WIP on master: 5d4ad47 Merge branch 'feature/...' into 'master'
Encountered 1 file(s) that should have been pointers, but weren't:
        public/apple-touch-icon.png

λ git pull
Updating 5a4ad44..b25f79d
error: Your local changes to the following files would be overwritten by merge:
        public/apple-touch-icon.png
Please commit your changes or stash them before you merge.
Aborting

λ git lfs migrate import
migrate: Fetching remote refs: ..., done
migrate: Sorting commits: ..., done
migrate: Rewriting commits: 100% (0/0), done
migrate: Updating refs: ..., done
migrate: checkout: ..., done


λ git pull
Updating 5d4ad47..a25c79a
Fast-forward
 public/apple-touch-icon.png | Bin 2092 -> 130 bytes
 public/favicon.ico          | Bin 6518 -> 1150 bytes
 2 files changed, 0 insertions(+), 0 deletions(-)

看见https://github.com/git-lfs/git-lfs/issues/2839