0

How can I detect the changes (say line by line if different at all) between two different git users (and their last commit)?

mona@DESKTOP-0JQ770H:/mnt/c/june1st_branch$ git log --pretty=format:"%H"  --after "2017-03-30 00:00"
17e24f8f66eda0b831ed2296482c7a4d42a8a0ba
6af4704ae5e2aacbdc52b4ad3057458158656c11
c6d33cc7fe7d4a86540589efdaa42b56ccd73a73
mona@DESKTOP-0JQ770H:/mnt/c/june1st_branch$ git log --pretty=format:"%H"  --after "2017-03-29 00:00"
17e24f8f66eda0b831ed2296482c7a4d42a8a0ba
6af4704ae5e2aacbdc52b4ad3057458158656c11
c6d33cc7fe7d4a86540589efdaa42b56ccd73a73
7b86066431bc4139ef2bcbcc9ee31e248108592a
05d321cae73f46499e656f84b644dd2c9c244a5e
mona@DESKTOP-0JQ770H:/mnt/c/june1st_branch$ git log --pretty=format:"%H"  --after "2017-05-01 00:00"
17e24f8f66eda0b831ed2296482c7a4d42a8a0ba
6af4704ae5e2aacbdc52b4ad3057458158656c11
c6d33cc7fe7d4a86540589efdaa42b56ccd73a73

For example, March 29th was the last day user A committed to the repo (admin) and June 8th, is the last day, user B had a commit locally (not admin so can't push to master). I would like to know what are all the lines added by user B to the repo (or modified). Here's the last git status of user B:

mona@DESKTOP-0JQ770H:/mnt/c/june1st_branch$ git status
On branch master
Your branch is ahead of 'origin/master' by 3 commits.
  (use "git push" to publish your local commits)

nothing to commit, working directory clean

1 Answer 1

1

Finding the last commits of different autors

Given that your local master branch is ahead of origin/master and thus contains all relevant commits you can use git log to search the last commit of earch user:

git log --pretty=format:"%H" -1 --author=EMAIL

and then compare these to commits with

git diff COMMIT1 COMMIT2

however, it may contain other changes as well, if there are commits inbetween.

to view the changes of the found commits as diffs:

git show COMMIT1
git show COMMIT2

Explanation

  • https://git-scm.com/docs/git-log
  • git log shows newest first
  • search of the author: --author= (you can also search for committer, if that differs)
  • limit to 1 commit (i.e. the last one): -1

Pitfalls

If the commits are on different branches, git log can be used

  • with branch names
  • with --branches= and a search pattern for branch names
  • with --all, for all branches
2
  • In the second snippet, is it supposed to be COMMIT1 COMMIT2? :P
    – ethanwu10
    Jun 17, 2017 at 19:23
  • @ethanwu10: indeed, thanks for catching the typo! Fixed it. Jun 17, 2017 at 19:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .