How do I diff one branch with my default branch

后端 未结 3 831
一个人的身影
一个人的身影 2021-01-30 19:49

I switched to a branch on my local repo and noticed it gave me message showing x files updated. This surprised me as I didn\'t know there were any differences on that branch. H

3条回答
  •  孤城傲影
    2021-01-30 20:27

    To just list the files with differences, add the --stat option:

    hg diff --stat -r BRANCH1:BRANCH2
    

    This gives output like this:

    mypath/file1.cpp    |    1 -
    mypath/file2.cpp    |  143 ++++++++++
    mypath/file3.cpp    |   18 +-
    3 files changed, 160 insertions(+), 2 deletions(-)
    

    Or to clean up the output a bit, pipe it through sed to remove everything after the pipe symbols:

    hg diff --stat -r BRANCH1:BRANCH2 | sed "s/|.*$//g"
    

    This gives you just a list of the changed files and the summary line at the end:

    mypath/file1.cpp
    mypath/file2.cpp
    mypath/file3.cpp
    3 files changed, 160 insertions(+), 2 deletions(-)
    

提交回复
热议问题