当我试图在终端中拉入我的项目目录时,我看到以下错误:

harsukh@harsukh-desktop:~/Sites/branch1$ git pull origin master
U app/config/app.php
U app/config/database.php
U app/routes.php
Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>'
as appropriate to mark resolution, or use 'git commit -a'.

为什么git说“拉是不可能的,因为你有未合并的文件”,我该如何解决它?


当前回答

如果你不想让你的本地分支发生任何变化,我认为这是最好的方法

git clean -df
git reset --hard
git checkout REMOTE_BRANCH_NAME
git pull origin REMOTE_BRANCH_NAME

其他回答

我也有同样的问题 在我的案例中,步骤如下-

删除了所有以U(未合并)符号开始的文件。作为- - - - - -


U   project/app/pages/file1/file.ts
U   project/www/assets/file1/file-name.html

从master中提取代码


$ git pull origin master

检查状态


 $ git status

这是它出现的消息 分别有2个和1个不同的提交。 (使用“git pull”将远程分支合并到您的分支中) 你有未合并的路径。 (修复冲突并运行“git commit”)

Unmerged路径: (使用“git add…”来标记分辨率)

both modified:   project/app/pages/file1/file.ts
both modified:   project/www/assets/file1/file-name.html

增加了所有新的变化-


    $ git add project/app/pages/file1/file.ts
project/www/assets/file1/file-name.html

在head上提交更改


$ git commit -am "resolved conflict of the app."

〇推送密码


$ git push origin master

用这个图像可以解决哪一个问题

有一个简单的解决办法。但要做到这一点,你首先需要学习以下内容

vimdiff

为了消除冲突,您可以使用

git mergetool

上面的命令基本上为每个冲突文件打开本地文件、混合文件、远程文件(总共3个文件)。本地和远程文件只是供您参考,使用它们您可以选择在混合文件中包含(或不包含)什么。然后保存并退出文件。

只需执行以下命令:

git reset --hard

如果你不想让你的本地分支发生任何变化,我认为这是最好的方法

git clean -df
git reset --hard
git checkout REMOTE_BRANCH_NAME
git pull origin REMOTE_BRANCH_NAME

您在本地有一些文件需要合并,然后才能进行提取。您可以签出这些文件,然后拖动以覆盖本地文件。

git checkout app/config/app.php app/config/database.php app/routes.php
git pull origin master