9. Changes, not files

Goals

Understanding that git works with the changes, not the files.

Most version control systems work with files. You add the file to source control and the system tracks changes from that moment on.

Git concentrates on the changes to a file, not the file itself. A git add file command does not tell git to add the file to the repository, but to note the current state of the file for it to be commited later.

We will try to investigate the difference in this lesson.

01 First Change: Adding default page tags

Change the “Hello, World” page so that it contained default tags <html> and <body>.

Please note that hello.html is listed in the status twice. The first change (the addition of default tags) is staged and ready for a commit. The second change (adding HTML headers) is unstaged. If you were making a commit right now, headers would not have been saved to the repository.

Let’s check.

05 Commit

Commit the staged changes (default values), then check the status one more time.

The status command suggests that hello.html has unrecorded changes, but is no longer in the buffer zone.

06 Adding the second change

Add the second change to the staging area, after that run the git status command.

Run:

git add .
git status

Note: The current directory (‘.’) will be our file to add. This is the most convenient way to add all the changes to the files of the current directory and its folders. But since it adds everything, it is a good idea to check the status prior to doing an add ., to make sure you don’t add any file that should not be added.

I wanted you to see the “add .” trick, and we will continue adding explicit files later on just in case.