View the change history of a file using Git versioning

后端 未结 24 1993
臣服心动
臣服心动 2020-11-22 16:40

How can I view the change history of an individual file in Git, complete details with what has changed?

I have got as far as:

git log -- [filename]
         


        
24条回答
  •  余生分开走
    2020-11-22 17:15

    git log --follow -p -- path-to-file

    This will show the entire history of the file (including history beyond renames and with diffs for each change).

    In other words, if the file named bar was once named foo, then git log -p bar (without the --follow option) will only show the file's history up to the point where it was renamed -- it won't show the file's history when it was known as foo. Using git log --follow -p bar will show the file's entire history, including any changes to the file when it was known as foo. The -p option ensures that diffs are included for each change.

提交回复
热议问题