WEBVTT

00:06.380 --> 00:07.520
Until this point.

00:07.520 --> 00:15.680
We know that git tracks two files in my repository, file one and file two, and it doesn't track the

00:15.680 --> 00:25.310
whole temp directory and config text file because we excluded these files to be tracked with git with

00:25.310 --> 00:29.920
the help of git ignore file in the previous lesson.

00:29.930 --> 00:33.650
Now let me change these files by adding some content to it.

00:33.680 --> 00:42.560
I'll type hostname command and redirect the output of this command to file one and I'll type who am

00:42.560 --> 00:42.710
I?

00:42.740 --> 00:51.080
Command and redirect this content, this output to the file to after making changes to these files and

00:51.080 --> 00:51.920
saving them.

00:51.920 --> 00:56.660
Let's see how git reacts by running git status command.

00:56.660 --> 01:01.370
As you can see, it shows that certain changes have been made to two files.

01:01.370 --> 01:08.990
We can also see exactly what was changed in the files, but running the following command git diff.

01:08.990 --> 01:16.730
The diff command shows the changes that have been made to the direct files in the repository since the

01:16.730 --> 01:17.810
last command.

01:17.810 --> 01:23.960
In the output, we can see green lines starting with a plus sign.

01:23.960 --> 01:32.810
It shows what's been added and the red line starting with a minus sign shows what's been removed.

01:32.810 --> 01:36.830
When you add it a line of code, the same thing happens.

01:36.830 --> 01:44.390
The old line is shown in red with a minus sign and the new version of the line is shown in green with

01:44.390 --> 01:45.770
a plus sign.

01:45.770 --> 01:53.000
If you want to check the changes in a single file, add the file name after the diff command.

01:53.000 --> 02:01.700
For instance, git diff file one and keep in mind that git diff command shows the changes only interact

02:01.700 --> 02:02.420
files.

02:02.420 --> 02:10.310
Now, after you've reviewed the changes you made, you need to stage the changes to be committed by

02:10.310 --> 02:13.160
typing git add file one.

02:13.160 --> 02:14.300
File two.

02:14.330 --> 02:21.590
Alternatively, you can add all tracked files like so git at dash you.

02:21.620 --> 02:29.090
Now that you've staged the files, they are ready to be committed and you can type git commit dash.

02:29.090 --> 02:29.690
Hm.

02:29.720 --> 02:31.940
And I'll type in double quotes.

02:31.940 --> 02:33.950
Added some info.

02:33.980 --> 02:42.350
I must say that it's a good habit to review the changes that you've made with git diff command and try

02:42.350 --> 02:46.370
to never stage files for commit before reviewing.

02:46.370 --> 02:49.990
So up to this point we have more than one commit.

02:50.000 --> 02:52.760
Let's explore a new area of git.

02:52.790 --> 02:54.740
The history of the project.

02:54.740 --> 03:01.160
The simplest way to review the history of a project is run in the following git log.

03:01.160 --> 03:05.600
This command shows the commits that we've made so far.

03:05.600 --> 03:13.550
The history shows the list of commits, each with a unique hash, an author, a timestamp and a commit

03:13.550 --> 03:14.480
message.

03:14.480 --> 03:17.180
This commit hash can be truncated.

03:17.180 --> 03:23.990
Usually five, four six characters are enough to identify the commit in a repository.

03:23.990 --> 03:34.280
For example, let me copy five first five characters of a commit and type git show and paste this truncated

03:34.280 --> 03:40.250
hash and the git show command lists information about a commit.

03:40.250 --> 03:46.850
So let's see how short we can go until git fails to identify the hash.

03:46.850 --> 03:51.130
I'll type get show and paste first five characters.

03:51.140 --> 03:56.840
Now let me truncate it up to four characters and git identifies it again.

03:56.840 --> 04:01.730
And if I truncate it up to three characters, it will fail.
