Overview

Teaching: 10 min
Exercises: 0 min
Questions
  • Where does Git store information?

Objectives
  • Create a local Git repository.

Once Git is configured, we can start using it. Let’s create a directory for our work and then move into that directory:

$ mkdir euroscipy2016
$ cd euroscipy2016

Then we tell Git to make euroscipy2016 a repository—a place where Git can store versions of our files:

$ git init

If we use ls to show the directory’s contents, it appears that nothing has changed:

$ ls

But if we add the -a flag to show everything, we can see that Git has created a hidden directory within euroscipy2016 called .git:

$ ls -a
.	..	.git

Git stores information about the project in this special sub-directory. If we ever delete it, we will lose the project’s history.

We can check that everything is set up correctly by asking Git to tell us the status of our project:

$ git status
# On branch master
#
# Initial commit
#
nothing to commit (create/copy files and use "git add" to track)

Places to Create Git Repositories

Dracula starts a new project, moons, related to his euroscipy2016 project. Despite Wolfman’s concerns, he enters the following sequence of commands to create one Git repository inside another:

cd             # return to home directory
mkdir euroscipy2016  # make a new directory euroscipy2016
cd euroscipy2016     # go into euroscipy2016
git init       # make the euroscipy2016 directory a Git repository
mkdir tutorials    # make a sub-directory euroscipy2016/tutorials
cd tutorials       # go into euroscipy2016/tutorials
git init       # make the tutorials sub-directory a Git repository

Why is it a bad idea to do this? How can Dracula undo his last git init?

Key Points