克隆后无法立即 git 恢复到较旧的提交(未进行任何更改)

发布于 2024-11-29 21:47:51 字数 372 浏览 1 评论 0原文

我需要测试 github 上一些代码的旧版本(提交)。我做了 git clone ,然后

git revert $id

&id 是我需要检查的版本的 id 。我收到此错误:

error: could not revert 9a0d90d... Version 1.2.1
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'

克隆后我没有对任何文件进行任何更改。

我做错了什么?

I need to test an older version (commit) of some code from github. I made git clone and then

git revert $id

where &id was id of the version that i need to check. I got this error:

error: could not revert 9a0d90d... Version 1.2.1
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'

I made no changes to any files after clone.

What am i doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

暮凉 2024-12-06 21:47:51

如果您想测试旧版本,您应该直接从您的旧 ID 创建一个分支

git checkout -b test $id

git revert 尝试计算一个新的提交,该提交将取消自 $id 以来引入的更改。计算负合并时可能会发生冲突。
您不需要它来咨询/测试旧版本。
如果您需要在该测试的上下文中进行任何更改,您将已经处于“test”分支中。

If you any to test an older version, you should create a branch directly from your older id

git checkout -b test $id

git revert tries to compute a new commit which would cancel changes introduced since $id. Conflicts can occurs when computing the negative merge.
You don't need that for consulting/testing an older revision.
And if you need to make any changes in the context of that test, you will already be in a 'test' branch.

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