案例是我想从远程存储库获取最新更新,所以我做git pull remoteRepository
不幸的是我遇到了冲突
$ git pull live master
git@123.xxx.xxx.xxx's password:
From 123.xxx.xxx.xxx:/home/git/myweb_live
* branch master -> FETCH_HEAD
...
...
Automatic merge failed; fix conflicts and then commit the result.
所以现在我在git status
On branch master
You have unmerged paths.
(fix conflicts and run "git commit")
Changes to be committed:
modified: backend/modules/agent/controllers/file1.php
modified: backend/modules/agent/controllers/file2.php
modified: backend/modules/agent/controllers/manyfile.php
modified: backend/modules/agent/views/agent/file1.php
modified: backend/modules/agent/views/agent/manyfile.php
Unmerged paths:
(use "git add <file>..." to mark resolution)
both modified: backend/runtime/debug/index.data
both modified: backend/runtime/logs/app.log
both modified: backend/runtime/logs/app.log.1
both modified: common/component/ScurityHelper.php
both modified: common/models/TbCustomer.php
我检查git log
,最新的提交仍然与远程存储库不同。
如何从远程存储库获取最新信息?
所以稍后我可以添加和提交我正在处理的文件,这些文件当前没有出现在上面的列表中,然后推送到远程存储库,而在其他机器中我拉动没有冲突。
如果我git commit
具有当前状态,我认为当我在git push之后从其他机器拔出时它会发生冲突。因为上面的文件不是我正在处理的文件。我想在我工作的地方添加我的文件。
提前致谢。
答案 0 :(得分:2)
有几种方法可以处理您的情况。
要取消暂存整个目录,您可以使用以下命令。
<强>命令强>
git rm --cached -r your_dir
另一个解决方案是在不再需要的情况下重置文件,但是这个命令非常危险,它会删除所有修改过的文件,你应该注意不需要哪些文件才能使用重置。
git reset --hard HEAD
或
git reset your_dir
另一种方法,
尝试检查已修改的文件夹,该文件夹将通过替换修改后的文件来检查主源文件中的最新文件。
git checkout your_dir