欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

git pull时遇到的问题及解决方法

程序员文章站 2022-06-19 10:57:52
...
[email protected]:learn$ git pull
Updating c626e62..e939e49
error: The following untracked working tree files would be overwritten by merge:
    apue/APUE-3rd.pdf
Please move or remove them before you merge.
Aborting
[email protected]:learn$ git status
On branch master
Your branch is behind 'origin/master' by 5 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    .DS_Store
    apue/APUE-3rd.pdf

nothing added to commit but untracked files present (use "git add" to track)

解决方法:

在使用Git pull时,经常会遇到报错:
Please move or remove them before you can merge

这是因为本地有修改,与云端别人提交的修改冲突,又没有merge.

如果确定使用云端的代码,最方便的解决方法是删除本地修改,可以使用以下命令:
使用下列命令:

git clean  -d  -fx ""
d  -----删除未被添加到git的路径中的文件
f  -----强制运行
x  -----删除忽略文件已经对git来说不识别的文件

注意:该命令会删除本地的修改,最好先备份再使用

git clean 参数
-n 显示 将要 删除的 文件 和 目录
-f 删除 文件,-df 删除 文件 和 目录

参考:
http://blog.csdn.net/chinacmt/article/details/52221733

相关标签: pll pull