解析合并后重置文件

时间:2017-08-25 22:30:00

标签: git

我偶然编辑了一个合并冲突中的文件,我并不打算在我所在的分支中进行编辑,现在我无法将文件还原回原点/主文件。不幸的是,在我将提交推送到远程分支之后,我才抓住它。以下是我尝试修复意外提交“a.cpp”时所遵循的步骤:

git diff origin/master a.cpp # Shows there are diffs
git checkout origin/master a.cpp 
git diff origin/master a.cpp # Shows there are NO diffs
git status # Shows that a.cpp has changed (which it should)
git add a.cpp
git status #shows that the files is staged for the commit
git commit -v # Verbose shows that nothing has changed!!!?
git diff origin/master a.cpp # Shows there are diffs AGAIN

似乎因为我解决了文件中的冲突,所以它拒绝更新到origin / master中的内容。如何强制将其更新为origin / master?

1 个答案:

答案 0 :(得分:0)

git status # Shows that a.cpp has changed (which it should)
git commit -v # Verbose shows that nothing has changed!!!?

似乎缺少git add .步骤。您需要在提交索引之前更新索引。

git checkout [<tree-ish>] [--] <pathspec>…​ 从索引文件或命名的<tree-ish>(通常是提交)更新工作树中的命名路径。