CS I · Wed Nov 11 · 15.3 · Do Now

Seeing a Change

Open the discussion form on the right and answer Section 1 from your first reading.

Announcements

Repositories, Diffs and Change Logs

This section explains where a project's history is kept, how to see exactly which lines one commit changed, and how a change log differs from that history.

What a Repository Holds

The previous lesson explained that each commit records the state of the whole project along with a message that describes the change, and Git stores all of those commits together in one place. A repository is a project's files together with their full history. Git keeps that history inside the project directory, in a hidden folder named .git, which stores every commit and every message. Because the whole history is stored there, a person can open any earlier version without asking another computer for it. For example, the class's Stops example is one repository, and it holds the current Stops.java along with the three commits that led to it. A folder of Java files on one Chromebook is not a repository, because it holds the files and none of their history. Nothing in that folder records what a file contained last week or why it was changed.

A repository can live on a single computer, and a copy of it can also be kept on a server, where the people who are allowed can reach it from any computer. Being on a server is not what makes a project a repository, since the files and their history together are what make it one. In this class, the example repository is the teacher's, and students read its history without making commits of their own.

How to Read a Diff

A history lists every commit, but a message alone does not show what changed in the code. A diff shows what changed between two versions of a file, usually one commit and the commit just before it. It shows the lines that were added and the lines that were removed. A removed line starts with a minus sign, and an added line starts with a plus sign. A line with no sign at the beginning is unchanged. Git shows three of those unchanged lines above and below each change by default, so that a reader can find the place in the file. The line that starts with @@ gives the line numbers where the change is.

Figure 1 is the real diff of commit 3 in the Stops example. It has one line removed, int stops = 5;, and one line added, int stops = 8;. This diff answers the Board Question, because Stops.java has the same number of lines as before, so counting lines would not locate the change, while the diff points directly at the one line that is different. The diff of commit 2, shown below, has two lines added and none removed.

diff --git a/Stops.java b/Stops.java
index 9f7ccaf..181b961 100644
--- a/Stops.java
+++ b/Stops.java
@@ -2,5 +2,7 @@ public class Stops {
     public static void main(String[] args) {
         int stops = 5;
         System.out.println(stops);
+        stops = stops - 1;
+        System.out.println(stops);
     }
 }

A diff has two limitations. First, it does not show the whole file again from top to bottom, because it shows only the changed lines and a few lines around them. Second, it does not explain why the change was made. The commit message says why, and the message for commit 3 is "Start at 8 stops because the route has 8."

What a Change Log Is For

Git makes the history and the diff, but a third record is written by a person. A change log is a list of the notable changes in a project, newest first, with the date of each version, written for the people who use the project. The history lists every commit exactly as it was made, while a change log is written afterward and keeps only the information a reader needs. For example, the change log for the Stops example has one line for Nov 4, which reads "The countdown now starts at 8." Git did not produce that line, because a person wrote it for someone who uses the program and does not need to read the code. The guide Keep a Changelog advises against using a list of commits as a change log. Such a list is full of noise, such as commits with unclear titles, that a user does not need.

These three records serve three different audiences. The history is for anyone tracing how the work went, one commit at a time. The diff is for anyone checking one change line by line. The change log is for someone who uses the program and wants to know what is different about it.

Summary

A repository is a project's files together with their full history, and it can live on one computer or be copied to a server. A diff shows the lines that one commit added and removed, with a minus sign on each removed line and a plus sign on each added line. A change log is written by a person and lists only the notable changes, newest first, for the people who use the project.

Sources: Chacon and Straub, Pro Git, sections 1.3, 2.1, 2.2, 2.3 and 2.5 (2014); Git project, git-diff Documentation (n.d.); GNU Project, Detailed Description of Unified Format (n.d.); Lacan, Keep a Changelog 1.1.0 (n.d.); the Stops example repository (classroom data, 2026).

I Do questions
  1. notebook cue: repository

    Name two things a repository holds that a plain folder of Java files does not.

    Check

    A repository holds the history of every commit, so each earlier version can be opened again, and it holds the message that says why each change was made. A plain folder holds only the files as they are now. See What a Repository Holds, paragraph 1.

  2. notebook cue: diff

    In Figure 1, one line starts with a minus sign and the line under it starts with a plus sign. What happened to that line of Stops.java?

    Check

    The line was changed. The old line, int stops = 5;, was removed, and the new line, int stops = 8;, was added in its place, so the program now starts its countdown at 8. See How to Read a Diff, paragraphs 1 and 2, and Figure 1.

  3. notebook cue: change log

    The history has three commits, but the change log has one line for Nov 4. Who wrote that line, and who is it written for?

    Check

    A person wrote it, not Git. It is written for the people who use the program, who need to know what is different without reading the code. See What a Change Log Is For, paragraph 1.

Figure 1. The real diff of commit 3 in the Stops example, with its commit message on top, the removed line tinted rust and the added line tinted green.
I Do questions
  1. notebook cue: repository

    Name two things a repository holds that a plain folder of Java files does not.

    Check

    A repository holds the history of every commit, so each earlier version can be opened again, and it holds the message that says why each change was made. A plain folder holds only the files as they are now. See What a Repository Holds, paragraph 1.

  2. notebook cue: diff

    In Figure 1, one line starts with a minus sign and the line under it starts with a plus sign. What happened to that line of Stops.java?

    Check

    The line was changed. The old line, int stops = 5;, was removed, and the new line, int stops = 8;, was added in its place, so the program now starts its countdown at 8. See How to Read a Diff, paragraphs 1 and 2, and Figure 1.

  3. notebook cue: change log

    The history has three commits, but the change log has one line for Nov 4. Who wrote that line, and who is it written for?

    Check

    A person wrote it, not Git. It is written for the people who use the program, who need to know what is different without reading the code. See What a Change Log Is For, paragraph 1.

Repositories, Diffs and Change Logs

This section explains where a project's history is kept, how to see exactly which lines one commit changed, and how a change log differs from that history.

What a Repository Holds

The previous lesson explained that each commit records the state of the whole project along with a message that describes the change, and Git stores all of those commits together in one place. A repository is a project's files together with their full history. Git keeps that history inside the project directory, in a hidden folder named .git, which stores every commit and every message. Because the whole history is stored there, a person can open any earlier version without asking another computer for it. For example, the class's Stops example is one repository, and it holds the current Stops.java along with the three commits that led to it. A folder of Java files on one Chromebook is not a repository, because it holds the files and none of their history. Nothing in that folder records what a file contained last week or why it was changed.

A repository can live on a single computer, and a copy of it can also be kept on a server, where the people who are allowed can reach it from any computer. Being on a server is not what makes a project a repository, since the files and their history together are what make it one. In this class, the example repository is the teacher's, and students read its history without making commits of their own.

How to Read a Diff

A history lists every commit, but a message alone does not show what changed in the code. A diff shows what changed between two versions of a file, usually one commit and the commit just before it. It shows the lines that were added and the lines that were removed. A removed line starts with a minus sign, and an added line starts with a plus sign. A line with no sign at the beginning is unchanged. Git shows three of those unchanged lines above and below each change by default, so that a reader can find the place in the file. The line that starts with @@ gives the line numbers where the change is.

Figure 1 is the real diff of commit 3 in the Stops example. It has one line removed, int stops = 5;, and one line added, int stops = 8;. This diff answers the Board Question, because Stops.java has the same number of lines as before, so counting lines would not locate the change, while the diff points directly at the one line that is different. The diff of commit 2, shown below, has two lines added and none removed.

diff --git a/Stops.java b/Stops.java
index 9f7ccaf..181b961 100644
--- a/Stops.java
+++ b/Stops.java
@@ -2,5 +2,7 @@ public class Stops {
     public static void main(String[] args) {
         int stops = 5;
         System.out.println(stops);
+        stops = stops - 1;
+        System.out.println(stops);
     }
 }

A diff has two limitations. First, it does not show the whole file again from top to bottom, because it shows only the changed lines and a few lines around them. Second, it does not explain why the change was made. The commit message says why, and the message for commit 3 is "Start at 8 stops because the route has 8."

What a Change Log Is For

Git makes the history and the diff, but a third record is written by a person. A change log is a list of the notable changes in a project, newest first, with the date of each version, written for the people who use the project. The history lists every commit exactly as it was made, while a change log is written afterward and keeps only the information a reader needs. For example, the change log for the Stops example has one line for Nov 4, which reads "The countdown now starts at 8." Git did not produce that line, because a person wrote it for someone who uses the program and does not need to read the code. The guide Keep a Changelog advises against using a list of commits as a change log. Such a list is full of noise, such as commits with unclear titles, that a user does not need.

These three records serve three different audiences. The history is for anyone tracing how the work went, one commit at a time. The diff is for anyone checking one change line by line. The change log is for someone who uses the program and wants to know what is different about it.

Summary

A repository is a project's files together with their full history, and it can live on one computer or be copied to a server. A diff shows the lines that one commit added and removed, with a minus sign on each removed line and a plus sign on each added line. A change log is written by a person and lists only the notable changes, newest first, for the people who use the project.

Sources: Chacon and Straub, Pro Git, sections 1.3, 2.1, 2.2, 2.3 and 2.5 (2014); Git project, git-diff Documentation (n.d.); GNU Project, Detailed Description of Unified Format (n.d.); Lacan, Keep a Changelog 1.1.0 (n.d.); the Stops example repository (classroom data, 2026).

Table Talk
Stops.java has the same number of lines today as it did yesterday, but it prints something different. Name two ways to find the line that changed, and say which one is faster.

Each table picks the faster way and says what it would show for a change to one line.

Chromebooks stay closed while your table talks. Sections 1 and 2 of the discussion form are already done. After you talk, finish Section 3 right here under My View. Submit before the exit ticket.

This form has three sections. Section 1: answer today's Board Question. Section 2: after the reading. Section 3 opens later in class. Today's Board Question: Stops.java has the same number of lines today as it did yesterday, but it prints something different. Name two ways to find the line that changed, and say which one is faster.

CR 1. Board Question: Stops.java has the same number of lines today as it did yesterday, but it prints something different. Name two ways to find the line that changed, and say which one is faster. Give your answer and one reason.

Write your answer in your lab notebook, labeled CR 1.

MC 1. Think about your answer to the board question. Stops.java has the same number of lines today as it did yesterday, but it prints something different. Name two ways to find the line that changed, and say which one is faster. Which position is closest to yours now?

  • Read both versions side by side, line by line, until something is different.
  • Open the diff for the commit, which marks the line that was removed and the line that was added.
  • Run the program both times and guess the line from the output.

MC 2. (Reading claim 1) A repository keeps a project's files and their history together.

  • Agree
  • Disagree

MC 3. (Reading claim 2) A diff shows the whole file again from top to bottom.

  • Agree
  • Disagree

MC 4. (Reading claim 3) A change log is written by a person for the people who use the project.

  • Agree
  • Disagree

MC 5. (Reading claim 4) In Figure 1, the line that starts with a plus sign is the new version of the line, int stops = 8;.

  • Agree
  • Disagree

MC 6. (Reading claim 5) A diff says why a change was made.

  • Agree
  • Disagree

MC 7. (Reading claim 6) Git wrote the change log line "The countdown now starts at 8."

  • Agree
  • Disagree

MC 8. (Reading claim 7) A repository can live on one computer, without any server.

  • Agree
  • Disagree

MC 9. (Reading claim 8) The diff of commit 2 in the passage removes one line and adds one line.

  • Agree
  • Disagree

CR 2. (A different view) Write the view at your table that was most different from yours. If everyone agreed, write the strongest argument against your table's answer.

Write your answer in your lab notebook, labeled CR 2.

CR 3. Think about the Board Question again: Stops.java has the same number of lines today as it did yesterday, but it prints something different. Name two ways to find the line that changed, and say which one is faster. Do you have the same opinion as when you first answered the board question? If it is the same, what from the reading or table talk reaffirmed your opinion? If it is different, what from the reading or table talk changed your opinion?

Write your answer in your lab notebook, labeled CR 3.