<commit_before>---
layout: lesson
root: ../..
title: A Better Kind of Backup
level: novice
---
The first time we use Git on a new machine,
we need to configure a few things (we'll insert blank lines
between groups of shell commands to make them easier to read):

~~~
$ git config --global user.name "<NAME>"

$ git config --global user.email "<EMAIL>"

$ git config --global color.ui "auto"

$ git config --global core.editor "nano"
~~~

(Please use your own name and email address instead of Dracula's,
and please make sure you choose an editor that's actually on your system
rather than `nano`.)

Git commands are written `git verb`,
where `verb` is what we actually want it to do.
In this case,
we're telling Git:

*   our name and email address,
*   to colorize output,
*   what our favorite text editor is, and
*   that we want to use these settings globally (i.e., for every project),

The four commands above only need to be run once:
Git will remember the settings until we change them.
Once Git is configured,
we can start using Git.
Let's create a directory for our work:

~~~
$ mkdir planets

$ cd planets
~~~

and tell Git to make it a [repository](../gloss.html#repository):

~~~
$ 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 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 ask Git for the status of our project at any time like this:

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

We'll explain what `branch master` means later.
For the moment,
let's add some notes about Mars's suitability as a base.
(We'll `cat` the text in the file after we edit it so that you can see what we're doing,
but in real life this isn't necessary.)

~~~
$ nano mars.txt

$ cat mars.txt
Cold and dry, but everything is my favorite color

$ ls
mars.txt

$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#	mars.txt
nothing added to commit but untracked files present (use "git add" to track)
~~~

The "untracked files" message means that there's a file in the directory
that Git isn't keeping track of.
We can tell Git that it should do so like this:

~~~
$ git add mars.txt
~~~

and check that the right thing happened like this:

~~~
$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
#	new file:   mars.txt
#
~~~

Git now knows that it's supposed to keep track of this file,
but it hasn't yet recorded any changes for posterity.
To get it to do that,
we need to run one more command:

~~~
$ git commit -m "Starting to think about Mars"
[master (root-commit) f22b25e] Starting to think about Mars
 1 file changed, 1 insertion(+)
 create mode 100644 mars.txt
~~~

When we run `git commit`,
Git takes everything we have told it to save using `git add`
and stores a copy permanently inside the special `.git` directory.
This permanent copy is called a [revision](../../gloss.html#revision).
We use the `-m` flag (for "message")<commit_msg>Add warning about Git commit id<commit_after>---
layout: lesson
root: ../..
title: A Better Kind of Backup
level: novice
---
The first time we use Git on a new machine,
we need to configure a few things (we'll insert blank lines
between groups of shell commands to make them easier to read):

~~~
$ git config --global user.name "<NAME>"

$ git config --global user.email "<EMAIL>"

$ git config --global color.ui "auto"

$ git config --global core.editor "nano"
~~~

(Please use your own name and email address instead of Dracula's,
and please make sure you choose an editor that's actually on your system
rather than `nano`.)

Git commands are written `git verb`,
where `verb` is what we actually want it to do.
In this case,
we're telling Git:

*   our name and email address,
*   to colorize output,
*   what our favorite text editor is, and
*   that we want to use these settings globally (i.e., for every project),

The four commands above only need to be run once:
Git will remember the settings until we change them.
Once Git is configured,
we can start using Git.
Let's create a directory for our work:

~~~
$ mkdir planets

$ cd planets
~~~

and tell Git to make it a [repository](../gloss.html#repository):

~~~
$ 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 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 ask Git for the status of our project at any time like this:

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

We'll explain what `branch master` means later.
For the moment,
let's add some notes about Mars's suitability as a base.
(We'll `cat` the text in the file after we edit it so that you can see what we're doing,
but in real life this isn't necessary.)

~~~
$ nano mars.txt

$ cat mars.txt
Cold and dry, but everything is my favorite color

$ ls
mars.txt

$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#	mars.txt
nothing added to commit but untracked files present (use "git add" to track)
~~~

The "untracked files" message means that there's a file in the directory
that Git isn't keeping track of.
We can tell Git that it should do so like this:

~~~
$ git add mars.txt
~~~

and check that the right thing happened like this:

~~~
$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
#	new file:   mars.txt
#
~~~

Git now knows that it's supposed to keep track of this file,
but it hasn't yet recorded any changes for posterity.
To get it to do that,
we need to run one more command:

~~~
$ git commit -m "Starting to think about Mars"
[master (root-commit) f22b25e] Starting to think about Mars
 1 file changed, 1 insertion(+)
 create mode 100644 mars.txt
~~~

When we run `git commit`,
Git takes everything we have told it to save using `git add`
and stores a copy permanently inside the special `.git` directory.
This permanent copy is called a [revision](../../gloss.html#revision)
and in this case it is identify by `f22b25e` (your revision will
have another identifier).
We use the `-m` flag (for "message")
{'fraction_non_alphanumeric': 0.09532112757919209, 'fraction_numerical': 0.004068584713746004, 'mean_word_length': 3.647535449020932, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '320053', 'n_tokens_mistral': 2155, 'n_tokens_neox': 2020, 'n_words': 1101}