Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
Learn what "git init" does and how it works.
Our project for this course will be a simplified version of a web site for a company that makes gold, silver, and bronze medals to award at sporting events. If you launch a Treehouse Workspace using the button on this video's page, you'll see a medals
directory (directory is a fancy word for folder) with two files in it:
medals/medals.html
<!DOCTYPE html>
<html>
<body>
<p>We have a fine selection of medals.</p>
</body>
</html>
medals/bronze.html
<h1>Check out our bronze medals!</h1>
<p>Medallion: $20</p>
<p>Ribbon: $10</p>
You don't need to worry too much about the particular content of these files; if you really want to know more about HTML, visit our Introduction to HTML and CSS course.
You can create a repository within a project directory on your computer. That's what we'll do here.
We need to change into our project directory so we can turn it into a Git repo. If we type ls
and press Enter, it will run the ls
command. This lists files and directories within the current directory. By the way, the ls
command isn't part of Git, but it's a standard command on all Unix-like systems. It's worth your time to learn how to use it. We have more coverage of the ls
command in this video from our Introduction to the Terminal course.
- We can see our project directory,
medals
, in the output of ls. - To get into the
medals
directory:
cd medals
- The
cd
command is another important command that works on Linux, Mac and Windows systems.cd
is also covered in our Introduction to the Terminal course; you can learn more about it in this video. - Now that we're in the project directory, we need to initialize the new repository. We'll do this with the
git init
command.
git init
- Like all the Git commands we'll be using in this course, it starts with the name of the
git
executable, followed by a space. Then, we type the name of the subcommand we want to run, likeadd
orcommit
or, in this case,init
. - Press Enter to run it. Git will initialize a repository in the current directory, by creating a new directory named
.git
within it. - You won't see the
.git
directory at first. Butls
has a special command line option that will cause it to show all files, even hidden ones.
ls -a
- If we hit Enter to run it, we can see the
.git
directory in the output ofls
.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up