4

I have a source tree (of a PHP application) which was rsynced out of a git repository at a point in time.

Can I find the matching version in the repo (the last commit which is present in the source tree)? - What if there were some minor modifications to this exported, untracked version of the source tree?

It should be possible if the terms are defined correctly. Is there a tool or a builtin git utility to solve this problem?

vbence
  • 20,084
  • 9
  • 69
  • 118
  • @CharlesB I have a non version-controlled source tree. Also: devconsole's answer already seems more resource-friendly than any of the answers there. - Though I'm still waiting for a possibly less brute-force solution. – vbence May 06 '13 at 08:56
  • the duplicate also deals with a non version-controlled source tree :) and devconsole's answer is quite the same as the duplicate accepted answer. I don't think you can have a non-brute force solution – CharlesB May 06 '13 at 10:36

2 Answers2

3

There may be better solutions but you could copy the exported source tree back to the git working directory (without committing it) and then compare with previous revisions in a for loop. Here's an example on how this could work with a bash script:

for ((i=1; i<100; i++)); do
  echo $i
  git diff --shortstat HEAD~$i
done

Then look for the minimum number of changes.

devconsole
  • 7,875
  • 1
  • 34
  • 42
0

I tried with a project of mine. I did

rsync -avz [GIT_REPO_BARE] local-copy

then I cd to local-copy and I run a git log. Luckily, I had some commits not yet pushed to the remote git repo, so I pushed them. Then I simply looked for the commit the commit id I previously found earlier with git log. Is that what you looked for?

ThanksForAllTheFish
  • 7,101
  • 5
  • 35
  • 54
  • The source tree to compare is not version controlled. From `git log` I assume you also rsynced the .git directory (so in your version it is version controlled). – vbence May 06 '13 at 08:15