0

If the .git directory is unavailable in the local checkout, is it still possible to know what was the commit hash of the local checkout? Assume that the local checkout was periodically pushed to remote origin.

git status depends on the .git directory which is futile in this case.

I could make a bash script with a diff to loop around every commit. Hoping for something more elegant and less brute-force.

How did I end up here:

  1. I did a pip install <git_origin_repo>@<commit_hash> long ago.
  2. It had installed the pip package in the site-packages directory. The .git directory is not created as pip probably sees no further use for it.

Now, I am trying to find out which commit hash it was that I had installed the package with.

  • 1
    You can clone the repository (bare clone) in order to get the `.git`-directory. You can then try to find the hash of the tree object and look for the reference in the repository. – dan1st Dec 26 '20 at 18:28
  • @dan1st You mean: 0. Assume the already existing directory is in directory X. 1. Do a clone of the origin repo with "git clone <>" at a different location (say location Y). 2. Go through every single commit hash of this location Y and compare with X? – Vikramaditya Gaonkar Dec 26 '20 at 18:34
  • 2
    Does this answer your question? https://stackoverflow.com/q/45681223/6309111 – Dev-vruper Dec 26 '20 at 18:34
  • @Dev-vruper it does indeed. Thanks. I have requested to mark this question as duplicate. – Vikramaditya Gaonkar Dec 26 '20 at 18:36

0 Answers0