View the change history of a file using Git versioning

后端 未结 24 2002
臣服心动
臣服心动 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:22

    Summary of other answers after reading through them and playing a bit:

    The usual command line command would be

    git log --follow --all -p dir/file.c
    

    But you can also use either gitk (gui) or tig (text-ui) to give much more human-readable ways of looking at it.

    gitk --follow --all -p dir/file.c
    
    tig --follow --all -p dir/file.c
    

    Under debian/ubuntu, the install command for these lovely tools is as expected :

    sudo apt-get install gitk tig
    

    And I'm currently using:

    alias gdf='gitk --follow --all -p'
    

    so that I can just type gdf dir to get a focussed history of everything in subdirectory dir.

提交回复
热议问题