Skip to content

Commit a12a523

Browse files
authored
Merge pull request #106 from emcaulay/100_change_to_ssh
100 change to ssh
2 parents 4a1416f + 4cd94de commit a12a523

File tree

9 files changed

+292
-84
lines changed

9 files changed

+292
-84
lines changed

episodes/02-getting-started.md

Lines changed: 110 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,117 @@
11
---
2-
title: "Getting started with git"
3-
teaching: 20
2+
title: "Getting started with Git"
3+
teaching: 25
44
exercises: 0
55
questions:
66
- "What are repositories and how are they created?"
77
- "What do `add` and `commit` mean?"
88
- "How do I check the status of my repository?"
99
objectives:
10-
- "create a git repository"
11-
- "track changes to files using the git repository"
12-
- "query the current status of the git repository"
10+
- "create a Git repository"
11+
- "track changes to files using the Git repository"
12+
- "query the current status of the Git repository"
1313
keypoints:
1414
- "When you initialize a Git repository in a directory, Git starts tracking the changes you make inside that directory."
1515
- "This tracking creates a history of the way the files have changed over time."
1616
- "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."
1717
---
1818

19-
### Using Git
19+
### Setting up Git
2020

21-
One of the main barriers to getting started with git is the language. Although some of the language used in git is
22-
fairly self-explanatory, other terms are not so clear. The best way to get to learn the language - which consists of a
23-
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
24-
lesson. These commands will be explained as we proceed from setting up a new version-controlled project to publishing
25-
our own website.
21+
When we use Git on a new computer for the first time,
22+
we need to configure a few things. The basic elements of a configuration for Git are:
23+
24+
* your name and email address,
25+
* what your preferred text editor is,
26+
* set the name of your default branch (branches are an important component of Git that we will cover later)
27+
* and that you want to use these settings globally (i.e. for every project).
28+
29+
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/).
30+
31+
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.
32+
33+
Open your shell terminal window and type:
34+
35+
~~~
36+
$ git config --list
37+
~~~
38+
{: .language-bash}
39+
40+
On MacOS, without any configuration your output might look like this:
41+
42+
~~~
43+
credential.helper=osxkeychain
44+
~~~
45+
{: .output}
46+
47+
On Windows, without any configuration your output might look like this:
48+
~~~
49+
diff.astextplain.textconv=astextplain
50+
filter.lfs.clean=git-lfs clean -- %f
51+
filter.lfs.smudge=git-lfs smudge -- %f
52+
filter.lfs.process=git-lfs filter-process
53+
filter.lfs.required=true
54+
http.sslbackend=openssl
55+
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
56+
core.autocrlf=true
57+
core.fscache=true
58+
core.symlinks=false
59+
pull.rebase=false
60+
credential.helper=manager-core
61+
credential.https://dev.azure.com.usehttppath=true
62+
init.defaultbranch=main
63+
~~~
64+
{: .output}
65+
66+
Assuming you have not set up Git on your computer before, let's go ahead and add our information to our configuration now.
67+
68+
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/).
69+
70+
Type these two commands into your shell, replacing `Your Name` and the email address with your own:
71+
72+
~~~
73+
$ git config --global user.name "Your Name"
74+
$ git config --global user.email "yourname@domain.name"
75+
~~~
76+
{: .language-bash}
77+
78+
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:
79+
80+
~~~
81+
git config --list
82+
~~~
83+
{: .language-bash}
84+
85+
~~~
86+
user.name=Your Name
87+
user.email=yourname@librarian.la
88+
~~~
89+
{: .output}
90+
91+
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.
92+
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/)).
93+
However, the simplest `core.editor` values are `"notepad"` on Windows, `"nano -w"` on Mac, and `"nano -w"` on Linux.
94+
95+
For example:
96+
97+
~~~
98+
$ git config --global core.editor "notepad"
99+
~~~
100+
{: .language-bash }
101+
102+
~~~
103+
$ git config --global core.editor "nano -w"
104+
~~~
105+
{: .language-bash}
26106

107+
Lastly, we need to set the name of our default branch to `main.`
108+
109+
~~~
110+
$ git config --global init.defaultBranch main
111+
~~~
112+
{: .language-bash }
113+
114+
The `init.defaultBranch` value configures git to set the default branch to `main` instead of `master`.
27115

28116
### Creating a repository
29117

@@ -41,6 +129,17 @@ $ cd hello-world
41129
~~~
42130
{: .language-bash }
43131

132+
### Using Git
133+
134+
One of the main barriers to getting started with Git is the language. Although some of the language used in Git is
135+
fairly self-explanatory, other terms are not so clear. The best way to get to learn the language - which consists of a
136+
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
137+
lesson. These commands will be explained as we proceed from setting up a new version-controlled project to publishing
138+
our own website.
139+
140+
On a command line interface, Git commands are written as `git verb options`,
141+
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.
142+
44143
We will now create an empty git repository to track changes to our project. To do this we will use the git **init** command,
45144
which is simply short for *initialise*.
46145

0 commit comments

Comments
 (0)