Skip to content

Commit e669d37

Browse files
authored
Merge pull request #1 from LibraryCarpentry/gh-pages
Sync my fork with the source repo
2 parents d6c9df5 + 2cae033 commit e669d37

File tree

8 files changed

+276
-101
lines changed

8 files changed

+276
-101
lines changed

episodes/02-getting-started.md

Lines changed: 94 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,49 +16,102 @@ keypoints:
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
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-
2719
### Setting up Git
2820

2921
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:
3223

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).
3628

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/).
3930

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.
4132

33+
Open your shell terminal window and type:
4234

43-
[BitBucket](https://bitbucket.org/),
44-
[GitLab](https://gitlab.com/) or
45-
another Git host server
46-
after this lesson will include this information.
4735
~~~
48-
$ git config --global user.name "Vlad Dracula"
49-
$ git config --global user.email "vlad@tran.sylvan.ia"
36+
$ git config --list
5037
~~~
5138
{: .language-bash}
5239

53-
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:
6041

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:
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}
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`.
62115

63116
### Creating a repository
64117

@@ -76,6 +129,17 @@ $ cd hello-world
76129
~~~
77130
{: .language-bash }
78131

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+
79143
We will now create an empty git repository to track changes to our project. To do this we will use the git **init** command,
80144
which is simply short for *initialise*.
81145

0 commit comments

Comments
 (0)