1
00:00:00,534 --> 00:00:02,159
- [Instructor] Hi, welcome
back to the course.

2
00:00:02,159 --> 00:00:03,871
Over the next few videos,
we're going to go over

3
00:00:03,871 --> 00:00:07,017
some of the major Git
commands that you should know,

4
00:00:07,017 --> 00:00:10,156
just so you can start using
them in your projects from now.

5
00:00:10,156 --> 00:00:12,989
I'm here in a folder for the section

6
00:00:12,989 --> 00:00:14,229
and the first thing I'm going to do

7
00:00:14,229 --> 00:00:17,056
is I'm going to create
another folder for code.

8
00:00:17,056 --> 00:00:20,436
And as you know, if you're
using the Git in Bash

9
00:00:20,436 --> 00:00:22,767
in Windows or you're in Linux or Mac,

10
00:00:22,767 --> 00:00:25,409
you can do this and create a new directory

11
00:00:25,409 --> 00:00:28,339
and then you can change
directory and go into

12
00:00:28,339 --> 00:00:30,610
the code directory.

13
00:00:30,610 --> 00:00:33,799
I'm going to initialise a repository,

14
00:00:33,799 --> 00:00:36,581
a Git repository, in this code folder.

15
00:00:36,581 --> 00:00:38,608
And what that means is that Git will start

16
00:00:38,608 --> 00:00:41,919
being able to tell what
files I have changed

17
00:00:41,919 --> 00:00:44,037
and what files I have created.

18
00:00:44,037 --> 00:00:46,712
And in order to do that, all we have to do

19
00:00:46,712 --> 00:00:48,045
is say git init.

20
00:00:50,882 --> 00:00:55,842
And that says initialised
empty Git repository in there.

21
00:00:55,842 --> 00:00:59,047
Now, when we've initialised
a Git repository,

22
00:00:59,047 --> 00:01:02,537
we can unlock all of
the other Git commands.

23
00:01:02,537 --> 00:01:06,287
For example, a popular
command is git status.

24
00:01:08,448 --> 00:01:11,522
Git status tells us a few things.

25
00:01:11,522 --> 00:01:13,923
It tells us that we are on branch master,

26
00:01:13,923 --> 00:01:16,346
we're gonna look at what
branches are later on.

27
00:01:16,346 --> 00:01:18,604
It tells us this is the first commit,

28
00:01:18,604 --> 00:01:20,453
we haven't really done anything yet.

29
00:01:20,453 --> 00:01:23,172
And it also tells us
there's nothing to commit,

30
00:01:23,172 --> 00:01:25,821
that we can create or copy files in

31
00:01:25,821 --> 00:01:29,904
and then we can use git
add to track those files.

32
00:01:31,500 --> 00:01:34,086
So what I'm going to do is
I'm going to create a file.

33
00:01:34,086 --> 00:01:37,549
A simple way to create a file
using the Git Bash in Windows

34
00:01:37,549 --> 00:01:39,497
or just a terminal in Linux or Mac,

35
00:01:39,497 --> 00:01:41,830
is to use the touch command.

36
00:01:43,310 --> 00:01:45,878
For example, you can do touch app.py

37
00:01:45,878 --> 00:01:49,045
and that creates a file called app.py.

38
00:01:50,467 --> 00:01:52,745
Now, let's run git status again.

39
00:01:52,745 --> 00:01:55,131
And now you can see that we're still

40
00:01:55,131 --> 00:01:57,046
in branch master, that hasn't changed.

41
00:01:57,046 --> 00:01:58,593
This is still the initial commit,

42
00:01:58,593 --> 00:02:01,559
but now there are some untracked files.

43
00:02:01,559 --> 00:02:05,547
And it tells us to use git add to include

44
00:02:05,547 --> 00:02:07,992
in what will be committed.

45
00:02:07,992 --> 00:02:10,428
Git add is the command that lets us

46
00:02:10,428 --> 00:02:13,789
move files from the local file system

47
00:02:13,789 --> 00:02:15,959
to the staging area.

48
00:02:15,959 --> 00:02:17,639
If you remember from the presentation,

49
00:02:17,639 --> 00:02:20,208
the staging area is
what's gonna be committed,

50
00:02:20,208 --> 00:02:23,383
is adding things to be
created in a snapshot.

51
00:02:23,383 --> 00:02:25,716
So let's add git add app.py.

52
00:02:27,632 --> 00:02:30,249
Now, I'm going to clear the terminal

53
00:02:30,249 --> 00:02:32,971
and run git status again.

54
00:02:32,971 --> 00:02:34,808
And now we see that we're still

55
00:02:34,808 --> 00:02:37,204
on branch master, this is
still the initial commit,

56
00:02:37,204 --> 00:02:38,931
we've not committed anything yet.

57
00:02:38,931 --> 00:02:42,181
But now we see changes to be committed.

58
00:02:43,584 --> 00:02:47,438
And there's a new file that
we've added called app.py.

59
00:02:47,438 --> 00:02:49,250
Notice how Git notices a new file

60
00:02:49,250 --> 00:02:52,570
and it isn't something that
Git has seen in the past.

61
00:02:52,570 --> 00:02:55,155
It makes sense because
we've just created this file

62
00:02:55,155 --> 00:02:57,738
and we've not committed it yet.

63
00:02:58,697 --> 00:03:01,447
We can always use git rm --cached

64
00:03:02,616 --> 00:03:05,620
to unstage a file and remove
it from the staging area

65
00:03:05,620 --> 00:03:09,787
if we don't want to include
it in the next commit.

66
00:03:11,158 --> 00:03:14,575
The next thing to do is say git commit -m

67
00:03:16,594 --> 00:03:18,643
and here we can write a short message

68
00:03:18,643 --> 00:03:20,875
on what this commit includes.

69
00:03:20,875 --> 00:03:25,042
For example, I can add created
a simple Flask application.

70
00:03:26,038 --> 00:03:30,326
And that's a lie because the
file is empty but nevertheless.

71
00:03:30,326 --> 00:03:32,578
You can write a short
message so that in the future

72
00:03:32,578 --> 00:03:34,321
when you look back through your commits,

73
00:03:34,321 --> 00:03:37,359
you can see what each commit did.

74
00:03:37,359 --> 00:03:39,408
And it's important to have
reasonably descriptive

75
00:03:39,408 --> 00:03:40,741
commit messages.

76
00:03:42,224 --> 00:03:43,962
And then when that happens, you can see

77
00:03:43,962 --> 00:03:48,184
that in the root-commit
we added a new commit.

78
00:03:48,184 --> 00:03:49,844
And this commit since created a

79
00:03:49,844 --> 00:03:51,697
simple flask application.

80
00:03:51,697 --> 00:03:55,148
We are on branch master and we have

81
00:03:55,148 --> 00:03:59,296
generated a new commit and
this is the commit's code.

82
00:03:59,296 --> 00:04:01,401
Each commit has a specific code

83
00:04:01,401 --> 00:04:03,968
and that may come in handy later on.

84
00:04:03,968 --> 00:04:06,252
And it tells you how
many files are changed,

85
00:04:06,252 --> 00:04:08,437
how many lines of code you inserted

86
00:04:08,437 --> 00:04:12,053
and how many lines of code you've deleted.

87
00:04:12,053 --> 00:04:15,993
And finally, it also tells
you that it's created app.py.

88
00:04:15,993 --> 00:04:17,441
Don't worry about this for now,

89
00:04:17,441 --> 00:04:19,691
that's a bit more advanced.

90
00:04:20,537 --> 00:04:23,229
Okay, so this is how you add and commit

91
00:04:23,229 --> 00:04:24,857
files in Git.

92
00:04:24,857 --> 00:04:27,650
Now we're gonna look at
how we can put those files

93
00:04:27,650 --> 00:04:29,168
in GitHub.

94
00:04:29,168 --> 00:04:31,042
I'll see you in the very next video.

