Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] Retrieving parent branch name

Thanks a lot Matthias,

Sorry for the late reply. I ended up fetching all branches to local repo, and use RevWalk with MERGE_BASE filter on my branch and all other branches to find common ancestors between those branches and my branch. Then I walk on my branch to find the first one of those ancestors. Drawback is that any merge is considered a common ancestor, but this was acceptable for us.

On Sun, Feb 19, 2017 at 6:41 PM, Matthias Sohn <matthias.sohn@xxxxxxxxx> wrote:
On Sun, Feb 19, 2017 at 10:47 AM, Alaa Nassef <alan.125@xxxxxxxxx> wrote:
I'm working on a project where I create a bare repository from a remote one, and fetch only one branch. What I'm trying to find out now is the name of the parent branch (or more specifically, the commit on the parent branch where this branch was created from) to identify the commits that were done on this branch only. For example, if my repository has a RefSpec for branch featureA only, and this was created from branch development on remote from commit 123, what can I do to find out this info?

you can use git ls-remotes to find branches and the commit they currently point at in a remote repository.
Commits don't know on which branch they were created.

Git reflog tracks whenever a local branch or HEAD is moving to another commit. But reflogs can only be
accessed locally, there is no remote API to inspect them. Also reflogs may be deleted depending on the configured
expiration time.

-Matthias


Back to the top