Find when line was deleted

前端 未结 3 2103
礼貌的吻别
礼貌的吻别 2020-12-04 21:08

Earlier today I discovered that some code was missing from my Git repository. I knew some of the missing text, and the file that it was in, so I used git log -S\'missi

3条回答
  •  伪装坚强ぢ
    2020-12-04 21:16

    There is a great answer to this on Super User: Git: How do I find which commit deleted a line?

    git blame --reverse START.. file.ext
    

    This will show, for each line, the last commit where the line was present - say hash 0123456789. The next commit to follow will be the one which removed it. Use git log and search for hash 0123456789 and then its successor commit.

提交回复
热议问题