Show only changed lines without syntax with git diff

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite
1












I have a list of usernames that are in a text file. I update this file and commit it. I am looking for a way to get a list of the changes since the last commit.



I do not want any diff formatting at all, I just want to get an output that has usernames one per line (as they are added to each commit) since the last commit.



I can't find a setting that will remove all the git diff syntax from the output so it's purely a list new lines added only.



Example



Original file:



user1
user2
user3


I then add



user4
user5


Then commit.



I want to be able to do a git diff and see only:



user4
user5






share|improve this question





















  • This question shows how to do this with GNU diff, but git diff doesn’t support the relevant options.
    – Stephen Kitt
    Jun 15 at 10:52














up vote
0
down vote

favorite
1












I have a list of usernames that are in a text file. I update this file and commit it. I am looking for a way to get a list of the changes since the last commit.



I do not want any diff formatting at all, I just want to get an output that has usernames one per line (as they are added to each commit) since the last commit.



I can't find a setting that will remove all the git diff syntax from the output so it's purely a list new lines added only.



Example



Original file:



user1
user2
user3


I then add



user4
user5


Then commit.



I want to be able to do a git diff and see only:



user4
user5






share|improve this question





















  • This question shows how to do this with GNU diff, but git diff doesn’t support the relevant options.
    – Stephen Kitt
    Jun 15 at 10:52












up vote
0
down vote

favorite
1









up vote
0
down vote

favorite
1






1





I have a list of usernames that are in a text file. I update this file and commit it. I am looking for a way to get a list of the changes since the last commit.



I do not want any diff formatting at all, I just want to get an output that has usernames one per line (as they are added to each commit) since the last commit.



I can't find a setting that will remove all the git diff syntax from the output so it's purely a list new lines added only.



Example



Original file:



user1
user2
user3


I then add



user4
user5


Then commit.



I want to be able to do a git diff and see only:



user4
user5






share|improve this question













I have a list of usernames that are in a text file. I update this file and commit it. I am looking for a way to get a list of the changes since the last commit.



I do not want any diff formatting at all, I just want to get an output that has usernames one per line (as they are added to each commit) since the last commit.



I can't find a setting that will remove all the git diff syntax from the output so it's purely a list new lines added only.



Example



Original file:



user1
user2
user3


I then add



user4
user5


Then commit.



I want to be able to do a git diff and see only:



user4
user5








share|improve this question












share|improve this question




share|improve this question








edited Jun 15 at 9:48









andcoz

11.5k32938




11.5k32938









asked Jun 15 at 9:47









Michael

1012




1012











  • This question shows how to do this with GNU diff, but git diff doesn’t support the relevant options.
    – Stephen Kitt
    Jun 15 at 10:52
















  • This question shows how to do this with GNU diff, but git diff doesn’t support the relevant options.
    – Stephen Kitt
    Jun 15 at 10:52















This question shows how to do this with GNU diff, but git diff doesn’t support the relevant options.
– Stephen Kitt
Jun 15 at 10:52




This question shows how to do this with GNU diff, but git diff doesn’t support the relevant options.
– Stephen Kitt
Jun 15 at 10:52










2 Answers
2






active

oldest

votes

















up vote
2
down vote













You could grep the diff output combining lookahead/lookbehind:



git diff --unified=0 | grep -Po '(?<=^+)(?!++).*'



  • (?<=^+) is a positive lookbehind for line starting with +


  • (?!++) is a negative lookahead to prevent matching files headers starting with +++ a/path/to/file.

The --unified=0 git option is just there to reduce the numbers of line to filter removing diff context, it is optional though.



There is probably better, I'm not fluent in PCRE.






share|improve this answer




























    up vote
    2
    down vote













    Borrowing --unified=0 from kaiko answer I came to:



    git diff HEAD^ HEAD --unified=0 | tail +6 | sed -e 's/^+//'





    share|improve this answer





















      Your Answer







      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "106"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: false,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );








       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f449969%2fshow-only-changed-lines-without-syntax-with-git-diff%23new-answer', 'question_page');

      );

      Post as a guest






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      2
      down vote













      You could grep the diff output combining lookahead/lookbehind:



      git diff --unified=0 | grep -Po '(?<=^+)(?!++).*'



      • (?<=^+) is a positive lookbehind for line starting with +


      • (?!++) is a negative lookahead to prevent matching files headers starting with +++ a/path/to/file.

      The --unified=0 git option is just there to reduce the numbers of line to filter removing diff context, it is optional though.



      There is probably better, I'm not fluent in PCRE.






      share|improve this answer

























        up vote
        2
        down vote













        You could grep the diff output combining lookahead/lookbehind:



        git diff --unified=0 | grep -Po '(?<=^+)(?!++).*'



        • (?<=^+) is a positive lookbehind for line starting with +


        • (?!++) is a negative lookahead to prevent matching files headers starting with +++ a/path/to/file.

        The --unified=0 git option is just there to reduce the numbers of line to filter removing diff context, it is optional though.



        There is probably better, I'm not fluent in PCRE.






        share|improve this answer























          up vote
          2
          down vote










          up vote
          2
          down vote









          You could grep the diff output combining lookahead/lookbehind:



          git diff --unified=0 | grep -Po '(?<=^+)(?!++).*'



          • (?<=^+) is a positive lookbehind for line starting with +


          • (?!++) is a negative lookahead to prevent matching files headers starting with +++ a/path/to/file.

          The --unified=0 git option is just there to reduce the numbers of line to filter removing diff context, it is optional though.



          There is probably better, I'm not fluent in PCRE.






          share|improve this answer













          You could grep the diff output combining lookahead/lookbehind:



          git diff --unified=0 | grep -Po '(?<=^+)(?!++).*'



          • (?<=^+) is a positive lookbehind for line starting with +


          • (?!++) is a negative lookahead to prevent matching files headers starting with +++ a/path/to/file.

          The --unified=0 git option is just there to reduce the numbers of line to filter removing diff context, it is optional though.



          There is probably better, I'm not fluent in PCRE.







          share|improve this answer













          share|improve this answer



          share|improve this answer











          answered Jun 15 at 11:49









          kaliko

          1058




          1058






















              up vote
              2
              down vote













              Borrowing --unified=0 from kaiko answer I came to:



              git diff HEAD^ HEAD --unified=0 | tail +6 | sed -e 's/^+//'





              share|improve this answer

























                up vote
                2
                down vote













                Borrowing --unified=0 from kaiko answer I came to:



                git diff HEAD^ HEAD --unified=0 | tail +6 | sed -e 's/^+//'





                share|improve this answer























                  up vote
                  2
                  down vote










                  up vote
                  2
                  down vote









                  Borrowing --unified=0 from kaiko answer I came to:



                  git diff HEAD^ HEAD --unified=0 | tail +6 | sed -e 's/^+//'





                  share|improve this answer













                  Borrowing --unified=0 from kaiko answer I came to:



                  git diff HEAD^ HEAD --unified=0 | tail +6 | sed -e 's/^+//'






                  share|improve this answer













                  share|improve this answer



                  share|improve this answer











                  answered Jun 15 at 21:21









                  Patrick Mevzek

                  2,0131721




                  2,0131721






















                       

                      draft saved


                      draft discarded


























                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f449969%2fshow-only-changed-lines-without-syntax-with-git-diff%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Popular posts from this blog

                      Peggy Mitchell

                      Palaiologos

                      The Forum (Inglewood, California)