Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9a61299
removed prereq number 3 from lesson index page because we want to cov…
emcaulay Jul 28, 2021
702e321
updated screenshot of repository url in github to show ssh
emcaulay Jul 28, 2021
3416cdb
updated the index page for the lesson to reference that this lesson w…
emcaulay Jul 29, 2021
cb392db
started edits of the episode 2 to add in the setting up git section (…
emcaulay Jul 29, 2021
59ffc5b
partial changes to episode 2, not yet finished, but ran out of time f…
emcaulay Jul 29, 2021
13884a7
additional edits to episode 2 to incorporate git config set up into t…
emcaulay Jul 30, 2021
cd04d76
some more progress on adding setting up Git to episode 2
emcaulay Jul 31, 2021
6159db5
completed episode 2 edits
emcaulay Aug 2, 2021
1f1e809
first edit to episode 3 for ssh inclusion; added screenshot to show b…
emcaulay Aug 2, 2021
124f09e
added another screenshot to Episode 3 to illustrate the create a new …
emcaulay Aug 2, 2021
6eab048
episode 3 changes in progress; switching from https to ssh
emcaulay Aug 2, 2021
c98ea33
completed full lesson update to switch SSH as the authentication prot…
emcaulay Aug 3, 2021
fde13b9
replaced Savvy Librarian as sample username with Your Name
emcaulay Aug 4, 2021
0fe34fa
changed sample user from Savvy Librarian to Your Name
emcaulay Aug 5, 2021
9bd1bbd
fixed one instance of Git not being capitalized
emcaulay Aug 5, 2021
41d7bc6
added full name for SSH at first instance instead of just the abbrevi…
emcaulay Aug 5, 2021
59a8761
removed extraneous line about that is not necessary for progressing t…
emcaulay Aug 5, 2021
8918fb1
revised sample email address to conform to yourname@domain.name, per …
emcaulay Aug 5, 2021
1401b98
updated link formatting for GitHub's privacy policy
emcaulay Aug 5, 2021
5f8e125
updated link formatting for GitHub's privacy policy (made a mistake i…
emcaulay Aug 5, 2021
3146853
re-instated more explicit instructions that learner should not click …
emcaulay Aug 5, 2021
c44ab96
made revision to index.md file as suggested by reviewer to provide co…
emcaulay Aug 5, 2021
c01f3d2
Update _episodes/03-sharing.md
emcaulay Aug 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 110 additions & 11 deletions _episodes/02-getting-started.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,117 @@
---
title: "Getting started with git"
teaching: 20
title: "Getting started with Git"
teaching: 25
exercises: 0
questions:
- "What are repositories and how are they created?"
- "What do `add` and `commit` mean?"
- "How do I check the status of my repository?"
objectives:
- "create a git repository"
- "track changes to files using the git repository"
- "query the current status of the git repository"
- "create a Git repository"
- "track changes to files using the Git repository"
- "query the current status of the Git repository"
keypoints:
- "When you initialize a Git repository in a directory, Git starts tracking the changes you make inside that directory."
- "This tracking creates a history of the way the files have changed over time."
- "Git uses a two-step process to record changes to your files. Changes to files must first be added to the staging area, then committed to the Git repository."
---

### Using Git
### Setting up Git

One of the main barriers to getting started with git is the language. Although some of the language used in git is
fairly self-explanatory, other terms are not so clear. The best way to get to learn the language - which consists of a
number of verbs such as `add`, `commit` and `push` (preceded by the word 'git') - is by using it, which is what we will be doing during this
lesson. These commands will be explained as we proceed from setting up a new version-controlled project to publishing
our own website.
When we use Git on a new computer for the first time,
we need to configure a few things. The basic elements of a configuration for Git are:

* your name and email address,
* what your preferred text editor is,
* set the name of your default branch (branches are an important component of Git that we will cover later)
* and that you want to use these settings globally (i.e. for every project).

First, we will tell Git our user name and email. For this lesson, we will be interacting with [GitHub](https://github.com/) and so we want to use the same email address we used when we set up our GitHub account. If you are concerned about privacy, please review [GitHub’s instructions for keeping your email address private](https://help.github.com/articles/keeping-your-email-address-private/).

It is possible you may have already set up Git on your computer in the past, so let's start by checking if there are any existing configurations.

Open your shell terminal window and type:

~~~
$ git config --list
~~~
{: .language-bash}

On MacOS, without any configuration your output might look like this:

~~~
credential.helper=osxkeychain
~~~
{: .output}

On Windows, without any configuration your output might look like this:
~~~
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
http.sslbackend=openssl
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
core.autocrlf=true
core.fscache=true
core.symlinks=false
pull.rebase=false
credential.helper=manager-core
credential.https://dev.azure.com.usehttppath=true
init.defaultbranch=main
~~~
{: .output}

Assuming you have not set up Git on your computer before, let's go ahead and add our information to our configuration now.

Please note: For this lesson, we will be interacting with [GitHub](https://github.com/) and so the email address used should be the same as the one used when setting up your GitHub account. If you are concerned about privacy, please review [GitHub’s instructions for keeping your email address private](https://help.github.com/articles/keeping-your-email-address-private/).

Type these two commands into your shell, replacing `Your Name` and the email address with your own:

~~~
$ git config --global user.name "Your Name"
$ git config --global user.email "yourname@domain.name"
~~~
{: .language-bash}

If you enter the commands correctly, the shell will merely return a command prompt and no messages. To check your work, ask Git what your configuration is using the same command as above:

~~~
git config --list
~~~
{: .language-bash}

~~~
user.name=Your Name
user.email=yourname@librarian.la
~~~
{: .output}

Let's also set our default text editor. A text editor is necessary with some of your Git work and the default from Git is vim, which is a great tool, but not useful if you're not familiar with it.
Any text editor can be made default by adding the correct file path and command line options (see [GitHub help](https://help.github.com/articles/associating-text-editors-with-git/)).
However, the simplest `core.editor` values are `"notepad"` on Windows, `"nano -w"` on Mac, and `"nano -w"` on Linux.

For example:

~~~
$ git config --global core.editor "notepad"
~~~
{: .language-bash }

~~~
$ git config --global core.editor "nano -w"
~~~
{: .language-bash}

Lastly, we need to set the name of our default branch to `main.`

~~~
$ git config --global init.defaultBranch main
~~~
{: .language-bash }

The `init.defaultBranch` value configures git to set the default branch to `main` instead of `master`.

### Creating a repository

Expand All @@ -41,6 +129,17 @@ $ cd hello-world
~~~
{: .language-bash }

### Using Git

One of the main barriers to getting started with Git is the language. Although some of the language used in Git is
fairly self-explanatory, other terms are not so clear. The best way to get to learn the language - which consists of a
number of verbs such as `add`, `commit` and `push` (preceded by the word 'git') - is by using it, which is what we will be doing during this
lesson. These commands will be explained as we proceed from setting up a new version-controlled project to publishing
our own website.

On a command line interface, Git commands are written as `git verb options`,
where `verb` is what we actually want to do and `options` is additional optional information which may be needed for the `verb`. So let's get started with our setup.

We will now create an empty git repository to track changes to our project. To do this we will use the git **init** command,
which is simply short for *initialise*.

Expand Down
Loading