2

Our team(quite a big team) use git, and I am git newbie.

After pulling from origin/master, I found my source is rollbacked. Some files commits are disappeared if I use just git log, but I can see the lost commits with log --full-history.

But How can I find who rollbacked my source and when?

rynmrtn
  • 3,371
  • 5
  • 28
  • 44
KwonNam
  • 686
  • 1
  • 8
  • 19
  • Do you mean the commit itself is disappeared or just the content of source file is reverted? – dyng Jun 20 '13 at 09:35
  • 3
    Yes, your question is a bit confused. If you can see the commit with "log --full-history", then it has obviously not "disappeared". Please indicate in your question 1) what you did 2) what you got as a result and 3) what you expected instead. Then we can help. – sleske Jun 20 '13 at 09:38
  • @dyng I edited the question. I can see the some commits only with '--full-history' option. but the hidden commits content is reverted. – KwonNam Jun 20 '13 at 10:09
  • @sleske : 1) I didn't do anything. I just pull the source from origin/master. 2) After pulling from origin/master, some of commits are hidden and the source files are reverted. 3) I just want to know who did this? and when? – KwonNam Jun 20 '13 at 10:10
  • this can happen because of forced updates, till you can check the history with git reflog, check similar http://stackoverflow.com/questions/10319110/how-to-detect-a-forced-update – maximus ツ Jun 20 '13 at 12:25
  • For your future, always commit with `-s`. In fact, make `commit -s` an alias for `commit`. `-s` makes the log signed, which not only tells who the authors/testers are, but also has some legal benefits. See [this question] for more information. – Shahbaz Jun 20 '13 at 12:47

1 Answers1

5

Have you tried?

$ git log --full-history {path/to/file}
...
commit 5574c123456c1c60e87fa072ea9cbe56ffe34a0
Merge:  d262137 be9c501
Author: {author}
Date:   Tue Jun 18 09:37:17 2013 -0400
... more commits ...

This shows a pretty good summary of the information you're likely looking for. In this example, we get the commit hash of the latest commits and if it is a merged commit, it will show both sides of the merge. To compare these, you could use a command like the following:

$ git diff d262137..be9c501 -- {path/to/file}

If you don't have a merge commit, you can simply git diff the latest commit hashes to see the differences.

rynmrtn
  • 3,371
  • 5
  • 28
  • 44
  • This answer is a common way of going about what you may have been doing. Perhaps you could give more information if you have not done a merge yet? Are you being proactively conscious of potential conflicts? – rynmrtn Jun 21 '13 at 11:57
  • It's not easy to explain, because of my poor English. I don't do anything. I'm just a reviewer. I pull the sources and reviewed. I never edit/commit/push sources. Someday I pull sources from master/origin and I found some commits are hidden(I can see couple of commits only with `--full-history` option), and some codes are reverted(Those are not my sources. Those are couple of programmers' sources in our team). The thing is nobody knows who did this, and when/how it happened. I need to know "who/how" to tell our team mates not to make the same mistake again. – KwonNam Jun 22 '13 at 08:13