WEBVTT
Kind: captions
Language: en

00:00:00.020 --> 00:00:05.600
In this video we're going to initialize
our project as a git repository

00:00:05.600 --> 00:00:06.280
git is a

00:00:06.299 --> 00:00:10.410
really useful tool that allows you to
keep track of all the changes that you

00:00:10.410 --> 00:00:15.120
make to your project before you can
start using git you need to initialize

00:00:15.120 --> 00:00:19.000
your project so it sets up the git
working files

00:00:19.000 --> 00:00:20.279
you initialize the git

00:00:20.279 --> 00:00:24.869
project by using the command line
interface for git so if we open up our

00:00:24.869 --> 00:00:30.359
terminal and then CD or change directory
to our project folder and then we can

00:00:30.360 --> 00:00:34.900
type git init to initialize our git
repository

00:00:34.900 --> 00:00:35.610
you know that the

00:00:35.610 --> 00:00:39.210
repository has been initialized if you get
this message saying initialized empty

00:00:39.210 --> 00:00:43.260
git repository in and then the path of
our project

00:00:44.040 --> 00:00:45.539
once the git repository has

00:00:45.539 --> 00:00:49.050
been initialized
let's open up atom and if you still have

00:00:49.050 --> 00:00:54.120
atom open from the previous videos then
close it first because we need to reload

00:00:54.120 --> 00:00:57.750
it completely in order to for it to
detect that the projects changed to a

00:00:57.750 --> 00:00:59.480
git repository

00:00:59.480 --> 00:01:01.260
alright so now I'm just going to reopen

00:01:01.260 --> 00:01:07.560
atom here and once atom is open I'm going to
go file add project folder and I'm going

00:01:07.560 --> 00:01:12.460
to add the project for our profiles REST
API in our courses workspace

00:01:13.240 --> 00:01:13.799
alright you

00:01:13.799 --> 00:01:17.189
can tell that the project has been
initialized as a git repository because

00:01:17.189 --> 00:01:22.759
of this icon here is changed from the
standard folder icon to this kind of

00:01:22.759 --> 00:01:28.710
like a folder icon and this means that
the project is now detected in atom as a

00:01:28.710 --> 00:01:33.509
git project and you also have this
hidden dot git directory here which will

00:01:33.509 --> 00:01:38.070
contain all of the working snapshots
that git stores as we make changes to

00:01:38.070 --> 00:01:42.600
our project now this folder is
completely managed by git so you should

00:01:42.600 --> 00:01:45.899
never need to go into this folder or
modify in any way it should happen

00:01:45.899 --> 00:01:48.420
automatically by the git tool

00:01:48.420 --> 00:01:51.420
ok now
that we have initialized our project

00:01:51.420 --> 00:01:57.000
let's go ahead and add some files to our
git project I'm just going to expand this

00:01:57.000 --> 00:02:03.450
window here and the first file that we're
going to create is the readme file it's

00:02:03.450 --> 00:02:07.320
best practice to create a readme file
with any project that you create because

00:02:07.320 --> 00:02:11.370
the purpose of the readme file is so
that if somebody finds the project or if

00:02:11.370 --> 00:02:15.290
you pick it up later on you may have
forgotten what it was the readme file can

00:02:15.290 --> 00:02:19.670
explain what it is and how to use it
we're just going to create an empty read

00:02:19.670 --> 00:02:25.880
me file by creating a new file and we'll
call it readme dot MD

00:02:25.880 --> 00:02:27.739
MD stands for markdown

00:02:27.739 --> 00:02:32.629
and this is kind of the latest industry
standard for writing documentation on

00:02:32.629 --> 00:02:34.900
git projects

00:02:34.900 --> 00:02:38.060
okay you can see that the
new file was created and is highlighted

00:02:38.060 --> 00:02:42.919
in green this means that it's a
additional file to our project since we

00:02:42.919 --> 00:02:48.230
last committed in git so since we've
never done a git commit any file that we

00:02:48.230 --> 00:02:53.959
add will automatically be green because
it hasn't been added yet so Atom knows

00:02:53.959 --> 00:02:58.370
that this files doesn't exist in our git
project and we need to add it so I'm

00:02:58.370 --> 00:03:02.510
going to show you how to add it in a bit
but first let's populate the readme file

00:03:02.510 --> 00:03:09.040
with just some basic things so I'm going to
create a hash here and hash is the

00:03:09.040 --> 00:03:15.109
basically the syntax for a heading in
our readme file now I'm not going to go

00:03:15.109 --> 00:03:19.609
into too much detail about how to write
markdown in this video but I will put a

00:03:19.609 --> 00:03:23.870
link in the resources of the video to a
page where you can learn how to write

00:03:23.870 --> 00:03:26.220
markdown files

00:03:26.220 --> 00:03:30.049
alright so the first
heading of our readme I'm going to put

00:03:30.049 --> 00:03:36.430
profiles rest API and then below this
I'm just going to put a description

00:03:36.430 --> 00:03:41.740
profiles rest api course code

00:03:41.740 --> 00:03:44.180
alright
let's save that file and now let's

00:03:44.180 --> 00:03:49.970
create the next file which is the git
ignore file whenever you're committing

00:03:49.970 --> 00:03:55.040
to a git project there are always some
files that is best practice to

00:03:55.040 --> 00:03:59.840
exclude from your git project these
include things like local database files

00:03:59.840 --> 00:04:04.310
and Python binary files that will be
created automatically when we run our

00:04:04.310 --> 00:04:09.949
project it's best practice to only
commit the basic text-based source code

00:04:09.949 --> 00:04:14.539
into our git project and the way you
separate the code that should be

00:04:14.539 --> 00:04:18.199
committed versus the code that is not
going to be committed is you use what's

00:04:18.199 --> 00:04:21.180
called a git ignore file

00:04:21.180 --> 00:04:24.110
the git ignore
file is simply a list of files that

00:04:24.110 --> 00:04:29.030
tells git don't add any of these files
or directories to our project when we do

00:04:29.030 --> 00:04:31.120
git commit

00:04:31.120 --> 00:04:35.060
okay so let's go ahead and
create our new git ignore file so if we

00:04:35.060 --> 00:04:43.240
type dot git ignore and I've created a
I've pre created a git ignore file

00:04:43.240 --> 00:04:47.240
specifically for this project and you
can find that in the resources of the

00:04:47.240 --> 00:04:52.810
video so if you click on that and then
we'll just load up the browser here and

00:04:52.810 --> 00:04:58.430
you can see that I have this git ignore
file here so this is the contents of the

00:04:58.430 --> 00:05:02.210
git ignore file that works for this
project it's a standard git ignore file

00:05:02.210 --> 00:05:09.590
for a Python and vagrant project and I'm
just going to copy all of this and I'm

00:05:09.590 --> 00:05:15.889
going to head over to Atom and I'm going to paste
it in the git ignore file alright now

00:05:15.889 --> 00:05:19.940
let's save that and you can see there's
a whole list of files here and I got

00:05:19.940 --> 00:05:25.009
these from this website called gitignore.io I'll also put this in the

00:05:25.009 --> 00:05:29.629
link in the resources of the video as
well but this is a website that allows

00:05:29.629 --> 00:05:33.650
you to generate a git ignore file for a
particular project and you can see here

00:05:33.650 --> 00:05:37.789
that I'm generating it for a Python and
a vagrant project and it pre-populates

00:05:37.789 --> 00:05:42.259
with all of the things that are best to
exclude from your git project for these

00:05:42.259 --> 00:05:44.880
particular languages

00:05:44.880 --> 00:05:47.960
okay now we have
the git ignore file created let's create

00:05:47.960 --> 00:05:51.409
the last file that we're going to do in
this video and that is the license file

00:05:51.409 --> 00:05:56.270
now because we're going to be pushing
our project to github and it'll be

00:05:56.270 --> 00:06:02.000
publicly accessible it's best practice
to include a license with the project

00:06:02.000 --> 00:06:07.310
and this is for two reasons one is to
show or make it clear to others what

00:06:07.310 --> 00:06:11.719
they're allowed to do with this code if
they want to reuse it and the second is

00:06:11.719 --> 00:06:15.409
to protect yourself so they can't sue
you if anything goes wrong because you

00:06:15.409 --> 00:06:19.729
basically say in the license that
there's no warranty or liability

00:06:19.729 --> 00:06:24.169
accepted for anything that happens with
this project so let's create a new file

00:06:24.169 --> 00:06:29.479
and let's call it license you can just
call it a license it doesn't have to

00:06:29.479 --> 00:06:33.860
have an extension on the end and then in
the resources I've linked to the MIT

00:06:33.860 --> 00:06:38.779
license now this is a permissive license
that allows basically anyone to do

00:06:38.779 --> 00:06:42.400
anything with this code
since this is course code I'm happy for

00:06:42.400 --> 00:06:46.720
anyone to take it and use it as they
like so I'm just going to copy the contents

00:06:46.720 --> 00:06:52.000
of this license here and then go back to
the atom editor and paste it and then

00:06:52.000 --> 00:06:57.159
just update the year to the current year
so it's currently 2019 and where it says

00:06:57.159 --> 00:07:00.819
full name I'm going to put my company name
but feel free to use your own name if

00:07:00.820 --> 00:07:02.340
you don't have a company

00:07:05.680 --> 00:07:08.919
Alright so
let's save this file and now we're ready

00:07:08.919 --> 00:07:13.020
to make our first commit to our gt
project

00:07:13.020 --> 00:07:14.530
the way that you commit to a git

00:07:14.530 --> 00:07:18.340
project is you use the terminal and the
first thing you need to do is use the

00:07:18.340 --> 00:07:23.650
git add command to add any new files
which have been added to our project so

00:07:23.650 --> 00:07:30.340
let's type git add dot this will add all
of these green files to our project and

00:07:30.340 --> 00:07:34.840
get them ready to be committed if you
don't type git add then it doesn't

00:07:34.840 --> 00:07:38.949
automatically add new files to our git
project so you have to run this command

00:07:38.949 --> 00:07:44.440
anytime that you've added or removed
files from the project alright next

00:07:44.440 --> 00:07:51.789
we're going to type git commit
- am and what this does is it says git

00:07:51.789 --> 00:07:56.080
commit and the a is for all and M is the
message so we're going to put the

00:07:56.080 --> 00:08:00.550
message in line here we're not going to
use the vim editor that it uses by default

00:08:00.550 --> 00:08:05.139
if you don't provide this m I prefer
to write the commits in line because

00:08:05.139 --> 00:08:09.940
it's just simpler that way so what you
do here is you just describe the changes

00:08:09.940 --> 00:08:13.440
that you've made to the project since
the last commit

00:08:13.440 --> 00:08:14.650
now since this is our

00:08:14.650 --> 00:08:21.000
first commit I'm just going to type
initial commit and hit enter

00:08:21.000 --> 00:08:26.560
alright and now it has committed the
files to our project that's how you

00:08:26.560 --> 00:08:31.110
create a git repository and add files to
it

