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

来源:互联网 发布:吉林广电网络集团 编辑:程序博客网 时间:2024/06/04 17:58
haohaibo@hhb:learn$ git pullUpdating c626e62..e939e49error: The following untracked working tree files would be overwritten by merge:    apue/APUE-3rd.pdfPlease move or remove them before you merge.Abortinghaohaibo@hhb:learn$ git statusOn branch masterYour 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.pdfnothing 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

原创粉丝点击