Hi, is there any way to also get the branch name of the branch the commits were made on by calling the endpoint from the REST API: https://api.bitbucket.org/2.0/repositories/{workspace}/{repo-slug}/commits?
Thank you!
Hello @Darius Bogdan,
This is not possible with Git, as in there's no way to do this by design. A branch in Git is just a pointer to a commit – a tip of that branch. When you create more commits on that branch, the pointer is moved to the new tip commit. However, it is possible to create commits updating any branches at all.
You can't tell which branch the commit was created at, even if there's a branch pointing to it: you can create a branch on any commit in your repository, after that commit was created. You also can remove any branch at any time, and there will be no traces of it (except for reflog which will "remember" that branch for some time), while the commits might still be reachable from other refs which will prevent them from being removed by garbage collector.
This is one of the significant differences between Git and Mercurial. The latter embeds the branch into commit metadata, so a commit always belongs to a branch. In Git, however, you can only answer a question "which branch has the specified commit", which means that commit is reachable from the tip of the branch if you follow links to commit's parents.
Does this make sense? Let me know if you have any questions.
Cheers,
Daniil
Yes, this makes sense. Thank you for the quick response.
Regards.
Darius
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.