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

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

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

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

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


当前回答

如果要推送所有文件,请尝试此操作git push—强制使用租赁原始主机

其他回答

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

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

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

希望这有帮助!

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

git reset --hard
git pull origin master

实例

[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

git-stash-save——保持索引对我不起作用。

下面的命令按预期工作。

git reset --hard
git pull

如果您不需要,它会覆盖所有本地更改。

出现错误“您对以下文件的本地更改将被合并覆盖”,因为您在本地回购中有一些尚未提交的更改,因此在从远程回购中提取之前,只需提交本地回购中的更改。

假设您的远程回购有一些分支xyz并且您希望将远程repo xyz分支合并到(复制到)本地repo xyx分支,

{
git checkout xyz                  //check out to the respective branch in local repo
git commit -m "commiting message" //commit changes if any, in local repo branch xyz
git pull                          //it pulls remote xyz branch into local xyz branch
}