Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaks up 01-backup.md in several topics #58

Merged
merged 14 commits into from
Mar 17, 2015
856 changes: 0 additions & 856 deletions 01-backup.md

This file was deleted.

65 changes: 65 additions & 0 deletions 01-setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
layout: page
title: Version Control with Git
subtitle: Setting Up Git
minutes: 10
---
> ## Learning Objectives {.objectives}
>
> * Explain which initialization and configuration steps are required once per machine,
> and which are required once per repository.

We'll start by exploring how version control can be used
to keep track of what one person did and when.
Even if you aren't collaborating with other people,
version control is much better for this than this:

[![Piled Higher and Deeper by Jorge Cham, http://www.phdcomics.com](fig/phd101212s.gif)](http://www.phdcomics.com)

"Piled Higher and Deeper" by Jorge Cham, http://www.phdcomics.com

The first time we use Git on a new machine,
we need to configure a few things.
Here's how Dracula sets up his new laptop:

~~~ {.bash}
$ git config --global user.name "Vlad Dracula"
$ git config --global user.email "vlad@tran.sylvan.ia"
$ 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,
such as `notepad` on Windows.)

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:
the flag `--global` tells Git to use the settings for every project on this machine.

> ## Proxy {.callout}
>
> In some networks you need to use a proxy. If this is the case you may also
> need to tell Git about the proxy:
>
> ~~~ {.bash}
> $ git config --global http.proxy proxy-url
> $ git config --global https.proxy proxy-url
> ~~~
>
> To disable the proxy, use
>
> ~~~ {.bash}
> $ git config --global --unset http.proxy
> $ git config --global --unset https.proxy
> ~~~

76 changes: 76 additions & 0 deletions 02-create.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
layout: page
title: Version Control with Git
subtitle: Creating a Repository
minutes: 10
---
> ## Learning Objectives {.objectives}
>
> * Explain how to create a Git repository locally.

Once Git is configured,
we can start using it.
Let's create a directory for our work:

~~~ {.bash}
$ mkdir planets
$ cd planets
~~~

and tell Git to make it a [repository](reference.html#repository)—a place where
Git can store old versions of our files:

~~~ {.bash}
$ git init
~~~

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

~~~ {.bash}
$ ls
~~~

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

~~~ {.bash}
$ ls -a
~~~
~~~ {.output}
. .. .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:

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

> ## Places to Create Git Repositories {.challenge}
>
> The following sequence of commands creates one Git repository inside another:
>
> ~~~ {.bash}
> cd # return to home directory
> mkdir alpha # make a new directory alpha
> cd alpha # go into alpha
> git init # make the alpha directory a Git repository
> mkdir beta # make a sub-directory alpha/beta
> cd beta # go into alpha/beta
> git init # make the beta sub-directory a Git repository
> ~~~
>
> Why is it a bad idea to do this?
Loading