2

I have a git repository, which conatains a project. At a certain point (between May and Septermber 2013) somebody copied the files from the repo manually and without revision control and made changes to it. In the meantime many changes have been made to my repo. Now I want to see the changes that have been made by the other guy who copied the files manually. He didn´t merged my changes since he copied the files, so I can´t just diff the files from him and my repo at the current state.

So how can I find the commit where my repository matches the changed files the closest and diff it at that point?

edit: my problem is similar to this question, but I only know the timeframe.

Community
  • 1
  • 1
Apology11
  • 21
  • 3
  • possible duplicate of [Git: How can I find a commit that most closely matches a directory?](http://stackoverflow.com/questions/6388283/git-how-can-i-find-a-commit-that-most-closely-matches-a-directory) – Trudbert Aug 25 '14 at 14:20
  • You can easily get the list of commits that are in that timeframe; then the two problems are the same. – Matthew Strawbridge Aug 25 '14 at 15:17
  • And how do I do the for loop suggested there? I don´t have any revisions, just the timeframe (or commits in the timeframe)? – Apology11 Aug 25 '14 at 15:48
  • @Apology11 We'd like to keep answers separate from questions, so you should write a separate answer instead of editing your answer into the question. Self-answers are perfectly admissible, and a well-written answer may earn you additional reputation. – jub0bs Aug 26 '14 at 12:53

2 Answers2

0
  1. Fetch the other person's code:

    git remote add other url-to-other-persons-repo
    git fetch other
    
  2. Get a diff:

    git diff other/master
    
Fred Foo
  • 355,277
  • 75
  • 744
  • 836
  • The problem is that there is no repo of the other person, and also no commit history, as he copied the files manually ... and even if I make one now with his changes, I have all the changes I´ve done in that diff. – Apology11 Aug 25 '14 at 14:42
0

Solution: As Matthew Strawbridge suggested the solution from the other question works here too. Here is what I did:

#!/bin/sh
 for REV in $(git rev-list foreign/master --after=2013-05-01 --until=2013-09-01); do
 git diff --shortstat $REV >> ~/rdiffs.txt;
 echo "$REV" >> ~/rdiffs.txt;
done

Then I wrote a vba makro in Excel to sort the results:

Sub sort()

Dim Zeile, Nzeile As Integer

For Zeile = 2 To ActiveSheet.UsedRange.Rows.Count Step 2

    Rows(Zeile).Cells(1).Select
    Selection.Cut
    Nzeile = Zeile - 1
    Rows(Nzeile).Cells(2).Select
    ActiveSheet.Paste

Next

For Zeile = 2 To ActiveSheet.UsedRange.Rows.Count Step 1

    Rows(Zeile).EntireRow.Delete

Next

End Sub
Community
  • 1
  • 1
Apology11
  • 21
  • 3