What do two plus signs in a git diff mean?

前端 未结 2 1359
抹茶落季
抹茶落季 2020-12-31 02:23

I am doing a git diff and for the first time, I am seeing double plus-signs next to lines.

++        if ($field_name == $selected) {
++
++              


        
相关标签:
2条回答
  • 2020-12-31 02:55

    These lines are added since the last version.

    From the manual page:

    - static void describe(char *arg)
     -static void describe(struct commit *cmit, int last_one)
    ++static void describe(char *arg, int last_one)
    

    In the above example output, the function signature was changed from both files (hence two - removals from both file1 and file2, plus ++ to mean one line that was added does not appear in either file1 nor file2). Also eight other lines are the same from file1 but do not appear in file2 (hence prefixed with {plus}).

    See diff manual:

    https://www.kernel.org/pub/software/scm/git/docs/v1.7.3/git-diff.html

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

    The ++ in diff output is from a "combined diff", which is the default format for git diff when showing merges (or when using the -c, -cc or -m options)

    When viewing a combined diff, if the two files you're comparing have a line that's different from what they were merged into, you will see the ++ to represent:

    one line that was added does not appear in either file1 or file2

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