What is in a diff?


diff is a formatted display of the differences between two sets of files. Git displays diffs like this:

diff --git a/report.txt b/report.txt
index e713b17..4c0742a 100644
--- a/report.txt
+++ b/report.txt
@@ -1,4 +1,4 @@
-# Seasonal Dental Surgeries 2017-18
+# Seasonal Dental Surgeries (2017) 2017-18

 TODO: write executive summary.

This shows:

  • The command used to produce the output (in this case, diff --git). In it, a and b are placeholders meaning “the first version” and “the second version”.
  • An index line showing keys into Git’s internal database of changes. We will explore these in the next chapter.
  • --- a/report.txt and +++ b/report.txt, which indicate that lines being removed are prefixed with -, while lines being added are prefixed with +.
  • A line starting with @@ that tells where the changes are being made. Here, the line shows that lines 1-4 are being removed and replaced with new lines.
  • A line-by-line listing of the changes with - showing deletions and + showing additions. (We have also configured Git to show deletions in red and additions in green.) Lines that haven’t changed are sometimes shown before and after the ones that have in order to give context; when they appear, they don’t have either + or - in front of them.

Desktop programming tools like RStudio can turn diffs like this into a more readable side-by-side display of changes; you can also use standalone tools like DiffMerge or WinMerge.

You have been put in the dental repository. Use git diff data/northern.csv to look at the changes to that file. How many lines have been changed?

ans:1

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *




Calender

October 2020
M T W T F S S
 1234
567891011
12131415161718
19202122232425
262728293031