Creating a repository
Overview¶
In the following, we create the Git repository which we use throughout the workshop.
Tips for instructors
- Please make sure to properly introduce the actual example to motivate the participants.
- Please do not explain too much about branching because this is the focus of a later episode.
Checkpoints:
- Please make sure that everyone was able to initialize the repository.
Create the planets Git repository¶
Imagine we work at Universal Missions. Our famous new clients - Dracula, Wolfman and the Mummy - are looking for potential planets to migrate to. We are here to help them make a good decision. For that reason, we collect relevant information about different planets to support them. We store this information in text files and manage them with Git.
The Software Carpentries, CC-BY 4.0
Now, let us create the planets
Git repository:
mkdir planets
- Creates the new, empty directoryplanets
.cd planets
- Switches into the directoryplanets
.git init
- Initializes the current directory as a Git repository. You need to initialize a repository only once. Afterwards, every file in theplanets
directory (or any subdirectory) can be maintained as part of the version history. Finally, you can also initialize a non-empty directory for version control with Git.- The
.git
subdirectory contains all data, metadata, and configuration settings of the Git repository. Please be careful: If you delete this directory, the history of all your changes is lost! - Finally, we check the current repository status with the
git status
command:git status On branch main No commits yet nothing to commit (create/copy files and use "git add" to track)
- The
git status
command is really useful when working with Git on the shell. It provides a detailed overview about the repository status and hints about what you could do next. - Later, we explain in more detail the concept of branches. For now, please consider it as the default place in your repository where your commits go.
- The branch name might be
master
in your output instead. That is because the Git community is trying to adopt more inclusive language. The default branch will bemain
but for compatibility reasons this is not fully the case yet. We show you how you can change the default name branch later.
- The
Key points¶
git init
initializes a new Git repository.- You only need to initialize a directory for version control with Git once.