Git 恢复错误消息?

发布于 2024-12-18 07:56:53 字数 972 浏览 1 评论 0原文

在尝试恢复我对 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

单身情人 2024-12-25 07:56:53

问。什么冲突?

当后续版本更改相同的代码行时,合并该版本的反向补丁会产生冲突:合并冲突

编辑如果您要恢复最新提交,这意味着您进行了本地更改(请参阅git status)。不要忘记您可以进行暂存未暂存本地更改。要轻松查看所有本地更改,请使用

<前><代码> git diff HEAD

您应该打开未合并的文件 (git status) 来查看冲突的文件。您将看到 <<<<<=====>>>>> > 冲突标记很快就会出现。

您可以使用

git mergetool

Meld、KDiff3、Gvim 等更用户友好的工具来解决冲突。

Q. What conflict?

The conflict from merging the reverse patch of that revision, when later revisions changed the same lines of code: a merge conflict

Edit If you are reverting the latest commit, this means that you had local changes (refer to git status). Don't forget that you can have staged and unstaged local changes. To easily see all local changes, use

   git diff HEAD

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

git mergetool

to resolve the conflicts with more user-friendly tools like Meld, KDiff3, Gvim etc.

空袭的梦i 2024-12-25 07:56:53

您混淆了未跟踪文件和未暂存文件。

  • 未跟踪的文件对 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 added them (i.e. git status will show them in the Untracked 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 the Changes not staged for commit: section). These changes will be included in the next commit if you run git commit -a, but not if you run git 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.

甜味超标? 2024-12-25 07:56:53

我到达这里是因为 git revert HEAD~3 出了严重错误(因为提交历史是非线性的,并且过去几次提交中至少有一次是合并,所以 Git 不喜欢这样) )。

要回到我尝试 git revert 之前,您所要做的就是运行以下命令:

git revert --abort

这将撤消您在当前 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:

git revert --abort

That will undo all the reversions you made during the current git revert.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文