我使用的是Git 1.7.4.1。

我想从存储库中获得我的代码的最新版本,但我得到错误:

$ git pull
….
M   selenium/ant/build.properties
….
M   selenium/scripts/linux/get_latest_updates.sh
M   selenium/scripts/windows/start-selenium.bat
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'.

我已经删除了工具抱怨的文件的本地副本,但我仍然得到错误。

如何从远程存储库签出最新版本?


当前回答

在我听来你好像有核心自专制问题。核心。如果将CRLF换行签入存储库,那么selflf =true会出现您在Windows上描述的问题。试着禁用core。并执行硬重置。

其他回答

你必须先合并你的文件。查看git状态以查看需要合并的文件(意味着您需要首先解决冲突)。完成后,执行git add file_merged并再次执行pull操作。

通过运行这个命令,你会得到最新的标签,通常是你项目的版本:

git describe --abbrev=0 --tags

如果上面的命令不能帮助你使用这个方法:

转到你有Fork的git存档 单击“设置”。>向下滚动,单击“删除此存储库” 确认删除 再次Fork,并重新输入git克隆<url_git> 您已经有了最新的版本

案例1:不要关心局部变化

解决方案1:获取最新的代码并重置代码 Git获取来源 Git重置-hard origin/[tag/branch/commit-id: master] 解决方法2:删除文件夹后重新克隆 Rm -rf [project_folder] Git克隆[remote_repo]

案例2:关注局部变化

Solution 1: no conflicts with new-online version git fetch origin git status will report something like: Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded. Then get the latest version git pull Solution 2: conflicts with new-online version git fetch origin git status will report something like: error: Your local changes to the following files would be overwritten by merge: file_name Please, commit your changes or stash them before you can merge. Aborting Commit your local changes git add . git commit -m ‘Commit msg’ Try to get the changes (will fail) git pull will report something like: 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'. Open the conflict file and fix the conflict. Then: git add . git commit -m ‘Fix conflicts’ git pull will report something like: Already up-to-date.

更多信息: 我如何使用'git重置-硬头'恢复到以前的提交?

试试这段代码

cd /go/to/path
git pull origin master