I'm going to show you how to initialize
your project as a git repository. So the
first thing we're going to do is we're
going to load up atom and we're going to
make sure we have our project folder
open.
I had it open last so when I opened it up
it had by default the profiles rest API.
If you don't see the profiles rest
API here then click on file then add
project folder navigate to the workspace
we created in the previous lesson and
click on the profiles REST API and select
folder. You can close off these welcome
tabs if they're still open. So we're
going to start by creating a readme file.
A readme file is simply just a file that
we store without code that explains what
the project is called and what the
project is about. So what does our project
do. So we created it by right-clicking the
name of the project here and clicking
new file. I'm going to call the file
README all uppercase .md .md stands
for markdown. A markdown is a typical
markup language that's used for creating
readme files. So it's kind of been
adopted as the industry standard for
creating readme files with our projects.
I'm not going to go into too much detail about
how to create markdown files here in
this lesson. But I did add a
link to the resources of this video that
takes you to the github markdown cheat
sheet page that'll tell you everything
you need to know about making markdown
files. We're going to create a header and
the way that you do that in markdown is
you use a hashtag. So use a hashtag and
a space next to it, it's important you
have the space after it and type the
name of the heading. So we're going to
give it the heading of our project name.
The project is called the profiles rest
api. Add a couple of spaces after that
and now we're going to type a
description of what our project is. So
our project is going to be creating
some basic functionality for managing
user profiles. So I'm just going to type
that. REST API providing basic
functionality for managing user profiles.
Okay so if someone looks at this file they see this
project they can open this file and they
can see the title of the project and
what the project is about. So save the
readme file. Next we're going to create a
git ignore file. So I mentioned that
we're going to be initializing our
project as a git repository. Git, if you
haven't heard of it before
is a version control system. It's used
for tracking changes in our source code.
So what you do is every time you make a
change you do what's called a git commit
and that takes a snapshot of what your
code looks like and it compares it to
the previous snapshot so it can see all
the changes in every file. So any file that
you've added, removed or any line that
you've added, removed or change git knows
and it keeps a track of every single one
so you can have a track of the
state of every single point in the
project since you began the project. The
git ignore file is a file that tells git
which files in our project do not need
to be added to git, so it's the files
that git should ignore. It's important to
have a git ignore file because there's
lots of other files that are created as a
byproduct of our source code or running
our source code, that we do not want to
commit into version control. We don't
want to commit them because they're not
easy to track the differences of and
they're going to be created new every
time a new developer comes and runs the
project code. So it's pointless to
commit them to git. The only things we
want to commit to git are just the basic
text files that make up our source code.
So start by right-clicking the profiles
REST API folder and click new file. And
we're going to create a get ignore file
and it needs to start with a dot and
then type get ignore and hit enter. It's
important that you spell it exactly as
it's spelled here otherwise git won't pick
it up as a git ignore file. Github has a
bunch of standard git ignore files for
different types of projects.
So depending
on what language you're using you're going
to have a slightly different git ignore
file. So github has kind of like a
repository of these which you can just
copy from. So I added a link to the
github python git ignore file in the
resources of this video. So click on that
link now and it will take you to the
python git ignore page. So you need to
copy the entire contents of this page
from bottom to top, right click copy and
just simply paste it into our window
into our git ignore file. I'll save
that. So now that we've added the readme
and the git ignore file, we're going to
commit our changes or we're going to
initialize our project as a git
repository and then we're going to
commit our changes. Earlier I showed you
the command prompt. Well on Windows git
installs a special version of the
command prompt called the git bash. So
click on start and type git bash and you
can see here the git bash desktop app. If
you're using a Mac or Linux then you
don't need to use the git bash, you can
just use the regular terminal that comes
with the operating system. Since we're
on Windows we're going to load up the
git bash and this is basically exactly
the same as the command prompt except it
gives us some extra features that help
us with managing our git repository.
So in the last lesson I showed you how
to use the change directory command. So
we're going to use it here to change
into our profiles REST API. So type CD
workspace/profiles rest
API and hit enter. This is going to switch us
to the working directory that
we're in here. So the profiles rest api.
So now to initialize our project as
a git repository simply type git init.
It stands for git initialized, and hit enter.
This initializes our project as an empty
git repository. The next step is to add
all of our files to the git repository
so every time you add new files to the
project you need to type git add run the
git add command
to add the files. So type git add and
then space and then you need to tell it
which files to add so you can specify
manually the files that you've added or
you can just type git add . and it
will just add all the files that it can
find in this directory. So type git add
. and now it adds the files and now we're
going to make our first commit. So every
single time that you make a change to
any of the files in the project we're
going to commit these files to git. You
do that by typing git commit and then
-a that stands for all so we want to
commit all the files that have changed
atleast. And then we need to type a
message. So you type -m open the speech
marks and we need to type a message
describing what we changed since the
last commit. So I always find it
important to write detailed commit
messages. This way you can easily keep
track of everything that you've changed
and also it helps you keep more focus on
the things that you've been working on.
So this is our first commit so I'm
going to type initial commit but I'm
also going to type that we added a git
ignore file and a readme file.
Remember to close the speech marks and
hit enter and there you go. That's our
first commit you can see it says here
initial commit and then it actually
outputted the message that we
put in. So the initial commit added
git ignore here it says two files
changed, a hundred insertions. This
hundred insertions is individual lines
which were added so I think there's, well
there's 98 here and there's four here so it's
a little bit more but I think it removed
some of the blank lines off the end. So
that's how you initialize a git project
and commit changes to the git repository.
Thank you so much for watching, I hope
you found this useful
and I'll see you in the next lesson.