我使用的是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'.
我已经删除了工具抱怨的文件的本地副本,但我仍然得到错误。
如何从远程存储库签出最新版本?
案例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重置-硬头'恢复到以前的提交?