Git 恢复错误消息?
在尝试恢复我对 .emacs.d 文件夹的存储库所做的提交时,我收到以下消息:
haziz@haziz> git revert 7fe3f
error: could not revert 7fe3f0b... .emacs.d contents from ubuntu hp 15
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
我正在尝试做的是反转我对 init.el 文件所做的更改,并随后执行了另一个提交试图扭转。我宁愿恢复而不是重置 --hard 因为据我所知后者完全删除了最近的提交。我想创建一个新的提交,以便我可以“恢复”恢复。
换句话说,我想做的就是
Git Commits [A]...[B]
将其恢复为
Git Commits [A]...[B]...[A']
我做错了什么吗?
编辑:我尝试尽可能地进行差异/合并,然后进行另一个提交,但它仍然给我这个新的错误消息:
haziz@haziz> git revert 7fe3f0ba3182b591f11c0b59e006dc6c990b7470
fatal: Your local changes would be overwritten by revert.
Please, commit your changes or stash them to proceed.
如何告诉它忽略(但不删除)未暂存的文件,无需求助于 .gitigore 文件。坦率地说,我不关心大多数未暂存的文件,即 emacs 临时文件等。
While trying to revert a commit I made to my repository of my .emacs.d folder I get the following message:
haziz@haziz> git revert 7fe3f
error: could not revert 7fe3f0b... .emacs.d contents from ubuntu hp 15
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
What I am trying to do is reverse changes I made to my init.el file and have followed with another commit which I am trying to reverse. I would prefer to revert rather than reset --hard since as far as I know the latter completely erases the most recent commit. I would like to create a new commit so that I can possibly "revert" the revert.
In other words what I am trying to do is this
Git Commits [A]...[B]
would be reverted to
Git Commits [A]...[B]...[A']
Am I doing something wrong?
Edit: I tried doing a diff/merge as best as I could then another commit but then it still gives me this new error message:
haziz@haziz> git revert 7fe3f0ba3182b591f11c0b59e006dc6c990b7470
fatal: Your local changes would be overwritten by revert.
Please, commit your changes or stash them to proceed.
How do I tell it to ignore (but not delete) unstaged files, without resorting to a .gitigore file. I frankly don't care about most of the unstaged files which are emacs temp files etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当后续版本更改相同的代码行时,合并该版本的反向补丁会产生冲突:合并冲突
您应该打开未合并的文件 (
git status
) 来查看冲突的文件。您将看到<<<<<
、=====
、>>>>>
> 冲突标记很快就会出现。您可以使用
Meld、KDiff3、Gvim 等更用户友好的工具来解决冲突。
The conflict from merging the reverse patch of that revision, when later revisions changed the same lines of code: a merge conflict
You should just open up the unmerged file (
git status
) to see the conflicted file(s). You'll see the<<<<
,=====
,>>>>>
conflict markers soon enough.You can use
to resolve the conflicts with more user-friendly tools like Meld, KDiff3, Gvim etc.
您混淆了未跟踪文件和未暂存文件。
未跟踪的文件对 Git 来说是未知的,您从未对它们进行过 git add 编辑(即
git status
将在Untracked files:
部分中显示它们) )。未暂存的文件是具有本地更改的跟踪文件,您没有暂存这些更改以进行提交(即
git status
将在Changes not staged for commit:
部分中显示它们)。如果您运行git commit -a
,这些更改将包含在下一次提交中,但如果您运行git commit
而没有-a
,则不会包含在下一次提交中。< /p>告诉 git 忽略未暂存的更改是没有意义的:更改就在那里,并且它们涉及 Git 关心的文件。
You're making a confusion between untracked files and unstaged files.
Untracked files are unknown to Git, you never
git add
ed them (i.e.git status
will show them in theUntracked files:
section).Unstaged files are tracked files which have local changes, which you did not stage for commit (i.e.
git status
will show them in theChanges not staged for commit:
section). These changes will be included in the next commit if you rungit commit -a
, but not if you rungit commit
without-a
.It does not make sense to tell git to ignore unstaged changes: the changes are there, and they touch files that Git cares about.
我到达这里是因为
git revert HEAD~3
出了严重错误(因为提交历史是非线性的,并且过去几次提交中至少有一次是合并,所以 Git 不喜欢这样) )。要回到我尝试 git revert 之前,您所要做的就是运行以下命令:
这将撤消您在当前 git revert 期间所做的所有还原。
I arrived here because a
git revert HEAD~3
went horribly wrong (since the commit history was non-linear, and at least one of the past few commits was a merge, so Git didn't like that).To go back to before I tried
git revert
, all you have to do is run this:That will undo all the reversions you made during the current git revert.