Using gitk to view the full history of a moved file

后端 未结 4 1165
渐次进展
渐次进展 2021-02-04 00:31

After much searching, I have not found a satisfactory method that is easy to use to view the complete history of a moved file in Git and more importantly in Gitk. Using gi

4条回答
  •  太阳男子
    2021-02-04 01:18

    Here's a bash function that should show you the history of a file (using gitk) in all its incarnations ... I'll leave it as an exercise to the reader if they need it for another shell:

    # bash
    gitk_follow () {
      while (( "$#" )); do
        git log --oneline --name-status --follow $1;
        shift;
      done | perl -ne 'if( s{^(?:[ACDMRTUXB]|R\d+)\s+}{} ) { s{\s+}{\n}g; print; }' | sort -u
    }
    
    # used as:
    gitk $(gitk_follow some_file)
    

    updated:

    Changed to use perl because I didn't pay close enough attention to the output from git log in the last version.

提交回复
热议问题