git reset commit_id with taxt dot无法通过jgit工作

发布于 2025-01-26 05:56:19 字数 791 浏览 7 评论 0原文

我创建了带有三个提交的Git Repo:

commit 99c3de6f701ed9e60d8a2fa0f7c435bc738685dc (HEAD -> master, origin/master, origin/HEAD)
    added c

commit 6a2e2b1fcb6cf54bb001c7f8618b623b10974cc2
    added b

commit e68e2a7e491a627e52d3ba83027897f800344843
    added a

in Git Shell git Reset E68E2A7E491A627E52D3BA83027897F800344843-。将存储库重置为第一个提交,并保留所有历史记录,并保留所有历史记录,并在第三提案中掌握了所有的掌握。

我尝试使用JGIT开发相同的命令:

ResetCommand reset = git.reset();
reset.setRef("e68e2a7e491a627e52d3ba83027897f800344843");
reset.addPath(".");
reset.call();

但是JGIT命令具有不同的行为 - 它将主重置为第一个提交,并且丢失了一些历史记录:

commit e68e2a7e491a627e52d3ba83027897f800344843 (HEAD -> master)
    added a

是一个错误还是我应该设计JGIT重置命令另一种获得所需行为的方法?

I created git repo with three commits:

commit 99c3de6f701ed9e60d8a2fa0f7c435bc738685dc (HEAD -> master, origin/master, origin/HEAD)
    added c

commit 6a2e2b1fcb6cf54bb001c7f8618b623b10974cc2
    added b

commit e68e2a7e491a627e52d3ba83027897f800344843
    added a

In git shell git reset e68e2a7e491a627e52d3ba83027897f800344843 -- . resets the repository to the first commit and keeps all history and HEAD point to MASTER at the third commit.

I've tried to develop the same command using JGIT:

ResetCommand reset = git.reset();
reset.setRef("e68e2a7e491a627e52d3ba83027897f800344843");
reset.addPath(".");
reset.call();

But JGIT command has different behavior - it resets MASTER to the first commit and some history lost:

commit e68e2a7e491a627e52d3ba83027897f800344843 (HEAD -> master)
    added a

Is it a bug or I should design JGIT reset command another way to get required behavior?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文