You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: episodes/02-getting-started.md
+94-30Lines changed: 94 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,49 +16,102 @@ keypoints:
16
16
- "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."
17
17
---
18
18
19
-
### Using Git
20
-
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.
26
-
27
19
### Setting up Git
28
20
29
21
When we use Git on a new computer for the first time,
30
-
we need to configure a few things. Below are a few examples
31
-
of configurations we will set as we get started with Git:
22
+
we need to configure a few things. The basic elements of a configuration for Git are:
32
23
33
-
* our name and email address,
34
-
* what our preferred text editor is,
35
-
* and that we want to use these settings globally (i.e. for every project).
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).
36
28
37
-
On a command line interface, Git commands are written as `git verb options`,
38
-
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.
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/).
39
30
40
-
First, we will tell Git your user name and email. It is important to pick a user name and email address that you want associated with your work because the user name and email address you use locally on your computer will be the same one that you use for your Git hosting websites. For this lesson we ill be using GitHub as a hosting service.
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.
Please use your own name and email address instead of Dracula's. This user name and email will be associated with your subsequent Git activity,
54
-
which means that any changes pushed to
55
-
[GitHub](https://github.com/),
56
-
[BitBucket](https://bitbucket.org/),
57
-
[GitLab](https://gitlab.com/) or
58
-
another Git host server
59
-
after this lesson will include this information.
40
+
On MacOS, without any configuration your output might look like this:
60
41
61
-
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][git-privacy].
42
+
~~~
43
+
credential.helper=osxkeychain
44
+
~~~
45
+
{: .output}
46
+
47
+
On Windows, without any configuration your output might look like this:
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:
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}
106
+
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`.
62
115
63
116
### Creating a repository
64
117
@@ -76,6 +129,17 @@ $ cd hello-world
76
129
~~~
77
130
{: .language-bash }
78
131
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
+
79
143
We will now create an empty git repository to track changes to our project. To do this we will use the git **init** command,
0 commit comments