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

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

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

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

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


当前回答

我从主人那里拉车时遇到了这种情况。

我使用Visual Studio处理它的方式;

首先,我对解决方案执行了撤销提交。然后我做了Git拉取过程。

希望这有帮助!

其他回答

如果您的存储库包含一些从master中删除的文件:

切换到主分支git获取原点git reset—硬原点/主git结帐-b newbranch

我有一个特殊的情况:我有个文件--假设它没有改变。很难找到,因为gitstatus命令没有显示任何更改

这对我来说很有用,我可以放弃实时远程服务器上的更改,并从源代码控制GitHub中提取:

git reset --hard
git pull origin master

这里有一个解决方案,可以丢弃阶段性更改:

git reset file/to/overwrite
git checkout file/to/overwrite

实例

[root@localhost www]# git pull
Username for 'http://159.65.151.11': amol
Password for 'http://amol@159.65.151.11':
remote: Counting objects: 34, done.
remote: Compressing objects: 100% (34/34), done.
remote: Total 34 (delta 13), reused 0 (delta 0)
Unpacking objects: 100% (34/34), done.
From http://159.65.151.11/OpenCC
   f793c8e..b8fe60c  v1.18.0_24Feb2022 -> origin/_v1.18.0_24Feb2022
error: Your local changes to the following files would be overwritten by merge:
        cc/routes/web.php
Please, commit your changes or stash them before you can merge.
Aborting

解决方案(忽略本地文件中已提交的更改)

git checkout HEAD^ cc/routes/web.php
git pull