Finding where program branched from a git library, without a .git -


i have problem, not unlike discussed @ step through file's history in git; similar p4v timelapse, sufficiently different.

i have git repository, 6 branches, 300+ files , 600+ commits.

i have body of code (uncommitted raw files) branch of same repository... without .git folder. in other words, have set of 300+ files, no history, no commit tags or hash numbers.

i want re-integrate informal branch, formal branch.

i need find commit copied, without .git, , subsequently edited.

how can efficiently, i.e. without performing manual 'checkout' of 600+ commits , running diff/meld , counting number of changed files?

you want find commit similar state of working directory. start creating local branch , committing 300+ files, become commit. then, use git diffs find commit similar.

the following script should trick. finds commits in given range, , estimates number of different lines between each commit , reference commit. finds minimal difference.

#!/bin/bash  commit_to_compare_with=d67e commit_range=1cb1d..e172  list_of_commits=($(git rev-list $commit_range)) num_of_commits=${#list_of_commits[@]} minimal_diff_count=100000000  echo echo found $num_of_commits commits in range $commit_range echo  count_lines_of_diff() { git diff $1 $2 | wc -l; }  c in "${list_of_commits[@]}"   diff_count=$(count_lines_of_diff $commit_to_compare_with $c)   echo ${c:0:4} differs ${commit_to_compare_with:0:4} $diff_count lines   if [ $diff_count -lt $minimal_diff_count ]       most_similar_commit=$c     minimal_diff_count=$diff_count   fi done  echo echo similar commit $commit_to_compare_with $most_similar_commit 

here's output i'm getting:

found 5 commits in range 1cb1d..e172  e172 differs d67e 45 lines 1431 differs d67e 26 lines 20e2 differs d67e 347 lines fb80 differs d67e 347 lines 8d67 differs d67e 360 lines  similar commit d67e 14310bc0cf69967d4781e0aec2fd2cca21d72ac6 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -