Count line differences after partially reversing staged edits

A tracked text file, notes.txt, contains 60 distinct lines in the current commit, identified by HEAD. Initially, its staged and working versions match that commit.


You make these changes in order:

  1. Delete original line 10, append eight new lines, and run git add -- notes.txt.
  2. Without staging again, restore original line 10 exactly in its original location, delete the last three of the eight appended lines, and append four entirely new lines.

All original and added lines have unique text. Surviving lines keep their relative order, every line ends with a newline, and there are no other edits, renames, filters or special diff settings. No commit is made.


Three file versions are connected by an editing and staging phase followed by an editing phase without staging.


The --numstat option reports inserted and deleted line counts separately. Determine both counts for git diff --numstat -- notes.txt and both counts for git diff --numstat HEAD -- notes.txt, after all the changes above. Give each answer as an exact integer number of lines.

Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Git Questions: