Get all files that have been modified in git branch

后端 未结 16 1602
深忆病人
深忆病人 2020-12-02 04:14

Is there a way to see what files have changed in a branch?

相关标签:
16条回答
  • 2020-12-02 04:30

    Considering you're on a feature branch and you want to check which files have changed compared to master... just this:

    git diff --name-only master
    
    0 讨论(0)
  • 2020-12-02 04:31

    I really liked @twalberg's answer but I didn't want to have to type the current branch name all the time. So I'm using this:

    git diff --name-only $(git merge-base master HEAD)
    
    0 讨论(0)
  • 2020-12-02 04:31
    git diff --name-only master...branch-name
    

    to which we want to compare.

    0 讨论(0)
  • 2020-12-02 04:31

    I use grep so I only get the lines with diff --git which are the files path:

    git diff branchA branchB | grep 'diff --git'
    // OUTPUTS ALL FILES WITH CHANGES, SIMPLE HA :)
    diff --git a/package-lock.json b/package-lock.json
    
    0 讨论(0)
  • 2020-12-02 04:35

    Expanding off of what @twalberg and @iconoclast had, if you're using cmd for whatever reason, you can use:

    FOR /F "usebackq" %x IN (`"git branch | grep '*' | cut -f2 -d' '"`) DO FOR /F "usebackq" %y IN (`"git merge-base %x master"`) DO git diff --name-only %x %y
    
    0 讨论(0)
  • 2020-12-02 04:36

    All you have to do is the following:

    git checkout <notMainDev>
    git diff --name-only <mainDev>
    

    This will show you only the filenames that are different between the two branches.

    0 讨论(0)
提交回复
热议问题