JGit检索一个提交ID的分支 [英] JGit retrieve branch on which a commitID was made

查看:927
本文介绍了JGit检索一个提交ID的分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从commitID检出时,git进入NO_BRANCH分离状态。所以我用来获取分支名称的JGit APi正在返回提交。所以我需要一种方式,在JGit API中,找到这个提交所在的分支。 使用分离的解析方案

- 分支模式(即从提交退出)实在不推荐: http:// sitaramc .github.com / concepts / detached-head.html



首先,我不知道如何获得提交SHA。通常你通过扫描一个分支来找到一个提交(例如使用日志)。所以你应该问自己的问题是你如何得到提交ID,你会从这些数据中找到分支。



对于你的具体问题,我想有一种方法根据RevCommit对象查找分支名称。然而,你应该知道这根本不是自然的。



如果你按照上面的链接,你就会明白Git是如何构建的以及为什么你的目标是获得一个提交从其他数据,而不是其他方式。

When I checkout from a commitID, git goes into a NO_BRANCH detached state. So the JGit APi which I use to get the branch name is returning the commit. So I need to a way, in JGit API, to find the branch on which this commit was made.

解决方案

Using the detached-branch mode (i.e. checking out from a commit) is really not recommended: http://sitaramc.github.com/concepts/detached-head.html

First of all, I do not know how you get the commit SHA. Usually you find a commit by scanning a branch (using log for example). So the question you should ask yourself is how you get the commit ID and you will find the branch from this data.

For your specific problem, I suppose there is a way to find the branch name based on the RevCommit object. However, you should know it is not natural at all.

If you follow the link above, you will understand how Git is constructed and why your goal is to get a commit from other data, and not the other way around.

这篇关于JGit检索一个提交ID的分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆