Show only changed lines without syntax with git diff

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
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
text-processing git diff
add a comment |Â
up vote
0
down vote
favorite
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
text-processing git diff
This question shows how to do this with GNUdiff, butgit diffdoesnâÂÂt support the relevant options.
â Stephen Kitt
Jun 15 at 10:52
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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
text-processing git diff
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
text-processing git diff
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 GNUdiff, butgit diffdoesnâÂÂt support the relevant options.
â Stephen Kitt
Jun 15 at 10:52
add a comment |Â
This question shows how to do this with GNUdiff, butgit diffdoesnâÂÂ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
add a comment |Â
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.
add a comment |Â
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/^+//'
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
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.
answered Jun 15 at 11:49
kaliko
1058
1058
add a comment |Â
add a comment |Â
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/^+//'
add a comment |Â
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/^+//'
add a comment |Â
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/^+//'
Borrowing --unified=0 from kaiko answer I came to:
git diff HEAD^ HEAD --unified=0 | tail +6 | sed -e 's/^+//'
answered Jun 15 at 21:21
Patrick Mevzek
2,0131721
2,0131721
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
This question shows how to do this with GNU
diff, butgit diffdoesnâÂÂt support the relevant options.â Stephen Kitt
Jun 15 at 10:52