1
00:00:00,230 --> 00:00:02,383
- [Instructor] Hi, and
welcome back to the course.

2
00:00:02,383 --> 00:00:03,564
In this video, we're going to look at

3
00:00:03,564 --> 00:00:05,596
what is a repository?

4
00:00:05,596 --> 00:00:07,726
This is important because Git is organised

5
00:00:07,726 --> 00:00:11,893
in a very specific way to
give you control and power.

6
00:00:13,308 --> 00:00:15,155
It's important to understand what Git is,

7
00:00:15,155 --> 00:00:19,322
because all Git commands
are used for one thing only.

8
00:00:20,517 --> 00:00:23,099
Git is a set of layers

9
00:00:23,099 --> 00:00:26,266
and each layer sort of has a function.

10
00:00:30,255 --> 00:00:31,847
The function is dependent on the layer

11
00:00:31,847 --> 00:00:34,484
but all you do with Git is you move files

12
00:00:34,484 --> 00:00:38,233
between these layers,
and the layers provide

13
00:00:38,233 --> 00:00:41,414
error control, redundancy,
and more things,

14
00:00:41,414 --> 00:00:45,916
so depending on the layer,
you get one thing or another.

15
00:00:45,916 --> 00:00:46,799
Let's look at these layers.

16
00:00:46,799 --> 00:00:49,522
The first layer is your filesystem.

17
00:00:49,522 --> 00:00:51,775
The filesystem is just your computer,

18
00:00:51,775 --> 00:00:54,525
so all the files that you've got.

19
00:00:55,390 --> 00:00:57,811
Git isn't this layer essentially,

20
00:00:57,811 --> 00:01:01,978
but this is the layer that
you've got before you use Git.

21
00:01:03,055 --> 00:01:06,992
Then, you can choose to initialise
Git in a specific folder.

22
00:01:06,992 --> 00:01:09,110
So you create a folder,
and you want this folder

23
00:01:09,110 --> 00:01:13,277
to be a Git repository, it
can initialise Git in it.

24
00:01:15,386 --> 00:01:19,127
Then, you've got this folder
with your Git repository in it,

25
00:01:19,127 --> 00:01:23,127
and so you create a file,
such as a Python file.

26
00:01:24,679 --> 00:01:29,414
These changes, that you've made
to this file you've created

27
00:01:29,414 --> 00:01:32,572
are not tracked by Git, by default,

28
00:01:32,572 --> 00:01:35,831
you have to tell Git that
you want to track this file.

29
00:01:35,831 --> 00:01:39,421
So what you do, is you tell
Git to include the files

30
00:01:39,421 --> 00:01:41,482
in the next snapshot.

31
00:01:41,482 --> 00:01:44,065
In this case, if it's only
one file, than you just add

32
00:01:44,065 --> 00:01:46,761
that file to the staging area.

33
00:01:46,761 --> 00:01:50,063
You add the file to the next commit.

34
00:01:50,063 --> 00:01:52,073
If you've incurred more
files, you can also add them

35
00:01:52,073 --> 00:01:54,020
to the staging area, and
eventually you end up

36
00:01:54,020 --> 00:01:58,134
with a staging area that has a few files,

37
00:01:58,134 --> 00:02:02,015
but changes are still not
tracked until you commit them;

38
00:02:02,015 --> 00:02:05,746
you create a snapshot of the files.

39
00:02:05,746 --> 00:02:07,787
So what you do, is you commit the files

40
00:02:07,787 --> 00:02:09,981
to the local repository,

41
00:02:09,981 --> 00:02:11,907
and this creates a snapshot of them.

42
00:02:11,907 --> 00:02:15,244
For example, if you create
a simple Flask application

43
00:02:15,244 --> 00:02:18,483
and you add it to the staging
area, and you commit it,

44
00:02:18,483 --> 00:02:21,894
that saves that file
in its current status.

45
00:02:21,894 --> 00:02:25,312
If you then add more code,
you will add it again

46
00:02:25,312 --> 00:02:27,288
to the staging area, and commit it again,

47
00:02:27,288 --> 00:02:30,214
and the changes between
version one and version two

48
00:02:30,214 --> 00:02:32,788
will be saved as a separate commit,

49
00:02:32,788 --> 00:02:34,304
and than as you do this more often,

50
00:02:34,304 --> 00:02:38,288
you may build up a history
of versions of your file,

51
00:02:38,288 --> 00:02:41,397
where each version has some more code.

52
00:02:41,397 --> 00:02:44,759
This means that you can go back
in time to a previous commit

53
00:02:44,759 --> 00:02:46,627
if you, for example, made a mistake,

54
00:02:46,627 --> 00:02:50,080
or you want to remove some code.

55
00:02:50,080 --> 00:02:53,370
Naturally, if your computer
blows up, you lose your files,

56
00:02:53,370 --> 00:02:55,915
because they are all in your computer,

57
00:02:55,915 --> 00:02:58,968
so the last thing to do,
is to host the snapshot,

58
00:02:58,968 --> 00:03:02,343
these commits, remotely,
so you can push these files

59
00:03:02,343 --> 00:03:05,461
to the cloud, and send them
to a Git service, like GitHub,

60
00:03:05,461 --> 00:03:09,294
or Bitbucket, these are
two separate services.

61
00:03:10,160 --> 00:03:13,484
A lot of people get confused
with GitHub and Git.

62
00:03:13,484 --> 00:03:16,373
Git is the thing that
allows you to move files

63
00:03:16,373 --> 00:03:20,540
between these layers and
allows you to commit and push.

64
00:03:21,611 --> 00:03:25,165
GitHub is essentially just a server

65
00:03:25,165 --> 00:03:27,448
that hosts your Git repository's

66
00:03:27,448 --> 00:03:30,838
so that you have a Git
repository in your computer,

67
00:03:30,838 --> 00:03:35,359
a local repository, and
also a remote repository;

68
00:03:35,359 --> 00:03:38,273
a repository that is hosted in GitHub.

69
00:03:38,273 --> 00:03:40,435
You are not limited to using
GitHub, so you could have

70
00:03:40,435 --> 00:03:43,691
a local repository, a
remote repository in GitHub,

71
00:03:43,691 --> 00:03:46,182
and a remote repository in Bitbucket,

72
00:03:46,182 --> 00:03:49,764
so you can have two remote
repositories for example.

73
00:03:49,764 --> 00:03:52,330
What's important to
remember is Git is the thing

74
00:03:52,330 --> 00:03:54,180
that allows you to do these things,

75
00:03:54,180 --> 00:03:58,347
GitHub is a server that hosts
your repository for you.

76
00:03:59,871 --> 00:04:03,871
So each layer has a
function, and it is optional

77
00:04:05,073 --> 00:04:07,399
to push your commits
to a remote repository,

78
00:04:07,399 --> 00:04:10,377
although again, if your
computer gets damaged,

79
00:04:10,377 --> 00:04:12,597
and you have your commits
in a remote repository,

80
00:04:12,597 --> 00:04:14,173
you can just download them again.

81
00:04:14,173 --> 00:04:16,333
So really it's helpful for redundancy

82
00:04:16,333 --> 00:04:19,232
and making sure you don't lose your data.

83
00:04:19,232 --> 00:04:22,832
And finally, the layers are all physical,

84
00:04:22,832 --> 00:04:25,398
it's not some sort of software magic.

85
00:04:25,398 --> 00:04:28,398
Git uses a folder called .git folder

86
00:04:30,531 --> 00:04:32,036
and whenever you make a new commit,

87
00:04:32,036 --> 00:04:33,528
that commit gets created there

88
00:04:33,528 --> 00:04:36,307
and it stores the new
snapshot and all those things,

89
00:04:36,307 --> 00:04:38,536
and when you push them to GitHub,

90
00:04:38,536 --> 00:04:40,598
all those snapshots get sent over

91
00:04:40,598 --> 00:04:44,468
and uploaded via your Internet
connection to GitHub servers.

92
00:04:44,468 --> 00:04:46,696
So there's no magic going on here.

93
00:04:46,696 --> 00:04:49,261
All Git is doing is
calculating the difference

94
00:04:49,261 --> 00:04:52,859
between your previous version
and your current changes

95
00:04:52,859 --> 00:04:55,966
and is storing those new
lines that you've added,

96
00:04:55,966 --> 00:04:58,777
that new code that you've added.

97
00:04:58,777 --> 00:05:00,553
And that's really all that Git is,

98
00:05:00,553 --> 00:05:05,361
is a way of storing snapshots,
and it is really helpful,

99
00:05:05,361 --> 00:05:07,332
because it means other
people can see your snapshots

100
00:05:07,332 --> 00:05:09,063
and than they can collaborate with you,

101
00:05:09,063 --> 00:05:11,039
and you can revert back
to previous snapshots,

102
00:05:11,039 --> 00:05:14,432
and you can host your snapshots
in the cloud for redundancy.

103
00:05:14,432 --> 00:05:17,843
So really, a great tool to
use, and I've not worked

104
00:05:17,843 --> 00:05:22,690
in a team that hasn't used
Git, so definitely something

105
00:05:22,690 --> 00:05:24,607
that you should learn.

