Calculating total lines added/deleted after a merge?

I recently took a branch with a lot of commits and merged it back into my master branch. If I needed to go back and see how many lines were added or deleted because of that merge, how would I go about doing that?

  • A way to revert a whole branch in a single commit
  • Why is there missing code in our Git repository and can it be solved with rebase?
  • unresolved deltas with git bundle
  • How do I discard unstaged changes in Git?
  • Two people working on a file at the same time in git
  • How to upload images to GitHub without gimmicks (on a Mac)?
  • How does Github detect mirrored repositories?
  • Git: compare local branch to remote staging and production
  • Git how to rollback a rebase
  • How to get files changed/removed/added using libgit2sharp?
  • cannot deploy to heroku because the key with fingerprint is not authorised
  • git rebase. How Do I Use it to Collapse Reams of Ancient Commits
  • 3 Solutions collect form web for “Calculating total lines added/deleted after a merge?”

    git diff has a --shortstat option which would have been useful before the merge as then you could’ve just done git diff --shortstat ..branch/to/merge from your main branch.

    If the merge wasn’t a fast-forward, then you’ll have generated a merge commit. That will have the parent information for both branches. You can use those to do git diff --shortstat parent1..mergecommit to show what changes happened when moving from the first parent (your main branch) to the result of the merge commit.

    If the merge was a fast-forward, then you just need to know what the sha1 of your branch was before the merge and compare that to the current. You could probably get that from git reflog.

    git diff --shortstat commit1 commit2
    

    should give you what you want:

    git diff --shortstat 8fcb60bebc18b9ee4a5a0a86d41e8ecf954b8c99 0214060c21f31f9b54446dde6b6e48901e6a144d
    5 files changed, 182 insertions(+), 225 deletions(-)
    

    See git tricks for more information:

    --shortstat
    

    Output only the last line of the --stat format containing total number of modified files, as well as number of added and deleted lines.


    Note:
    You can even use it to compute some daily activity

    https://jbowes.files.wordpress.com/2008/05/screenshot-git-graphpl.png?w=490&h=342

    Use a diff utility to compare the main branch version of the file before and after the merge.

    WinMerge (if you’re using Windows) would be a good one to use.

    Git Baby is a git and github fan, let's start git clone.