git show changes done by last 10 commits by me or anyone in a folder as a consolidated change
Reference to my original question
This is in continuation of that question
I have a git repository in which I have a folder. In this folder multiple people makes changes. I have recently made few commits in that directory .
In one commit I added few lines of code and in next commit I removed those lines.
Lets call these lines as X.
I want to:
view all changes that I have done in last 10 commits in that directory (ie changes done by me only) as a consolidated change where I see all changes in a file as a single space.
Ie for me I should not see those lines
Xand should see each file single time only
view all changes that anyone has done in that directory in last 10 commits as a consolidated change where i see all changes in a file as a single space.
Ie for me I should not see those lines X and should see each file single time only
2 Solutions collect form web for “git show changes done by last 10 commits by me or anyone in a folder as a consolidated change”
git diff is more suited than the previously suggested
git log then:
git diff @~10 @ -- path/to/folder or git diff HEAD~10 HEAD -- path/to/folder
@ being a shortcut for
HEAD, git 1.8.4+)
Note: as try-catch-finally rightly points out, this won’t work regarding author: authorship can be filtered at the commit level, not so much at the patch level.
That is why my answer to the previous question used
git log --author=xxx -p.
But to get the patches in one consolidated result though, git diff remains the right tool.
If you have one commit that adds files and another commit that removes them, you may want to consider interactive rebasing to squash those two commits together which will effectively remove the ‘inconsistent state commit’ that you probably want to eliminate.
Bring up the interactive rebasng editor with:
$ git rebase -i HEAD~10
Note that “
HEAD~10 is a ‘squiggly’ not a dash !