Home > Software design >  When was a feature branch opened, without checking out the whole repo?
When was a feature branch opened, without checking out the whole repo?

Time:01-27

I would like to read out the date, when a feature branch was opened, but don't want to checkout the whole repository.

In my "normal-cloned-repo" I can do a git log develop..feature/long-living-feature --oneline --reverse and see the first commit of the feature branch. (In fact, it is the first commit, after the feature branch has been merged back into develop, but I am okay with that. If I could also improve that, it would be nice, too. It would be nicer to find the commit from which the feature branch was created initially.)

Since I am writing a small application, which should generate a report, I don't want to clone a lot of repositories fully for that need. Because also the info of the last commit is required, I cloned the repo without files like that: git clone <url> <path> --filter=blob:none --no-checkout --single-branch --branch feature/long-living-feature.

Executing my above command in this repository throws the following error:

fatal: ambiguous argument 'develop..feature/long-living-feature': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git [...] -- [...]'

Looks like this repo is missing the references to develop, may be?

How can I read the date without checking out the full repository?

CodePudding user response:

Seems like I have found an answer:

First, get the last commit hashes of all branches:

git ls-remote --heads <url>

Then clone the repository with minimal size:

git clone <path> <url> --filter=tree:0 --no-checkout

Finally, use git merge-base to find the best common ancestor between two commits.

git merge-base <developHash> <branchHash>

And of course, e.g. a git show <hash> --format="

  •  Tags:  
  • Related