How to diff one file to an arbitrary version in Git?

前端 未结 13 2044
青春惊慌失措
青春惊慌失措 2020-12-07 07:12

How can I diff a file, say pom.xml, from the master branch to an arbitrary older version in Git?

13条回答
  •  南方客
    南方客 (楼主)
    2020-12-07 07:35

    If neither commit is your HEAD then bash's brace expansion proves really useful, especially if your filenames are long, the example above:

    git diff master~20:pom.xml master:pom.xml
    

    Would become

    git diff {master~20,master}:pom.xml
    

    More on Brace expansion with bash.

提交回复
热议问题