0

I want to fetch a commit that are in review with only knowing the short hash. Is that possible?

So I do not have the long-hash, commit-id etc. This is in a script that only gets the short hash so therefore I am wondering if it is possible with gerrit review request.

marcus.w
  • 19
  • 2
  • You can run `git fetch`, and then the commit will be available to be logged. – evolutionxbox Sep 21 '22 at 11:03
  • git fetch will only bring what is merged into master. This is a commit that is on master but it is not merged so will not see it with git fetch – marcus.w Sep 21 '22 at 11:13
  • When you say "in review", do you mean it's part of a merge request/pull request on a remote Git hosting site? You would need to tell us the specific site involved, because e.g. while both GitLab and GitHub allow you to check out pending requests, the process is different for each site. – larsks Sep 21 '22 at 11:32
  • @marcus.w _"git fetch will only bring what is merged into master"_ - [no it doesn't](https://git-scm.com/docs/git-fetch) – evolutionxbox Sep 21 '22 at 11:39
  • oh okey so... We are using gerrit for our repos. So we are commiting our changes to master and waiting for other to review it. This means it is not in latest master yet. I have tried to do git fetch but I cannot see the commit in git log. I need to do git fetch to get the commit. but the issue is that I dont have the full-hash – marcus.w Sep 21 '22 at 11:41
  • 2
    You've posted an example of the [XY problem](https://xyproblem.info/): what you want is to obtain the commits that are part of a Gerrit review request. You found a trick that works (feed full raw hash ID to Gerrit server) and have asked a Git-specific question, when you really wanted to ask [this question instead](https://stackoverflow.com/q/28370567/1256452). – torek Sep 21 '22 at 11:49
  • @torek the link you sent do not solve my issue. I still cannot get the commit with only the short-hash – marcus.w Sep 21 '22 at 13:19
  • That's correct: you *cannot* get the commit with only the short hash. In other words, the question you've asked ("is that possible") has a very short answer: "no". The question you *wanted* to ask, "how do I do this in general", does have an answer. – torek Sep 22 '22 at 04:09

0 Answers0