search

Home  >  Q&A  >  body text

How to find out file modification records, known codes and file names in git

A line of code in a file was modified to an incorrect code. How can I use the git command to find out who modified the code?
git blame filepath Since there are too many file modification records and all are displayed, how can we find the culprit more accurately and quickly

PHP中文网PHP中文网2804 days ago614

reply all(4)I'll reply

  • 黄舟

    黄舟2017-05-02 09:51:04

    git blame filepath | grep 'code'
    or
    git blame filepath | grep 'lineNO)'

    reply
    0
  • 世界只因有你

    世界只因有你2017-05-02 09:51:04

    You can use the sourcetree tool. In this tool, the operations are all interface-based, and it is more convenient to search for records.

    reply
    0
  • ringa_lee

    ringa_lee2017-05-02 09:51:04

    The fastest one is probably blame. Just find that line and see who wrote the commit

    You can also git log -p -M --follow --stat -- 文件名 and search

    reply
    0
  • 阿神

    阿神2017-05-02 09:51:04

    vim file.name Enter the file, move the cursor to this line, and then ":Gblame", the record of who modified this line will be displayed on the left.

    reply
    0
  • Cancelreply