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: version-control/command-line/tutorial.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,14 +15,14 @@ The following set of examples will help you understand how to use Git via the co
15
15
16
16
17
17
### Create and add your project in Git
18
-
To start, let's make a directory to store our files and initialise the directory as a Git repository on our local system.
18
+
To start, let's make a directory to store our files and initialise the directory as a Git repository on our local system. This is the same as we did in the [Set-up tutorial]((../set-up/tutorial.html)) previously.
19
19
20
20
```bash
21
21
$ mkdir practising-git
22
22
$ cd practising-git
23
23
$ git init
24
24
```
25
-
> The first command above will make a new directory (`mkdir`) at the system location you're at within the terminal window. The second command will change directory (`cd`) into the new one you just made. The third command will call the Git program then initialise (`init`) your directory as a local Git repository.
25
+
> You may recall this will make the directory, change directory so we're located in it, then initialise it as an empty Git repository.
26
26
27
27
### Create a file.
28
28
We can create a new file in our local directory and add a line to it at the same time, with the below.
Now that we know what Version Control is, let's get set-up with Git on our system and make sure we're ready to start creating our own projects and contributing to others.
8
+
Now that we know what Version Control is, let's get set-up with Git and Github on our system and make sure we're ready to start creating our own projects and contributing to others.
9
9
10
-
## Before you begin
11
-
Install command line Git for your operating system ([OS X](https://sourceforge.net/projects/git-osx-installer/), [Windows](http://msysgit.github.io/) or [Linux](https://git-scm.com/download/linux)) and open your terminal / command prompt.
10
+
## Install and Set-up Git
11
+
Install command line Git for your operating system ([OS X](https://sourceforge.net/projects/git-osx-installer/), [Windows](http://msysgit.github.io/) or [Linux](https://git-scm.com/download/linux)) and open a terminal / command prompt.
12
12
13
-
Download [Github Desktop](https://desktop.github.com/) for Mac or Windows.
13
+
Once installed check Git commands works by typing the following in the terminal window.
14
14
15
-
Now create a directory where you will be storing all your projects. You can call it something obvious such as `code` or `projects`.
15
+
```bash
16
+
$ git --version
17
+
```
18
+
This will return the version of Git you've installed and prove it's up and running correctly.
16
19
17
-
### Set-up your Account Git details
18
-
When we make a commit to a respository we need to associate it with ourselves. To do that we can tell Git our Github account username and email address
20
+
> Later in the tutorial we'll download [Github Desktop](https://desktop.github.com/).
19
21
20
-
commits
21
-
To associate commits you make to repositories to yourself, we need to set-up a Username
22
+
### Create an empty Git repository
23
+
Now create a directory where you will be storing all your projects, by typing the following lines and hitting enter after each. You can call the directory whatever you prefer, such as `code` or `projects`.
24
+
25
+
```bash
26
+
$ mkdir practising-git
27
+
$ cd practising-git
28
+
$ git init
29
+
```
30
+
31
+
> The first command above will make a new directory (`mkdir`) at the system location you're at within the terminal window. The second command will change directory (`cd`) into the new one you just made. The third command will call the Git program then initialise (`init`) your directory as a local Git repository
32
+
33
+
### Set-up your Git account details
34
+
When we make a commit to a respository we need to associate it with ourselves. To do that we can tell Git our Github account username and email address. Type the following lines in the terminal window.
22
35
23
36
```bash
24
37
$ git config --global user.name "Your Name"
25
38
$ git config --global user.email "name@domain"
26
39
```
27
40
28
-
### Setup an SSH key
41
+
### Set-up a SSH keys
42
+
In order to connect to and work with the host of a remote repository you'll need a way to prove who you are before a secure connection is allowed. If you think you may already have SSH keys set-up or just want to see what you have in place, use the following command.
43
+
44
+
```bash
45
+
$ ls -al ~/.ssh
46
+
```
47
+
> Notice this is a command line statement, not a Git statement.
48
+
> In the consoole window look for files named `id_rsa` and `id_rsa_pub`
49
+
50
+
There are two files to be generated as one is the Private Key that resides on your system and the other is the Public Key that can be shared and added to various services, such as Github, as the other part to authenticate you with.
51
+
52
+
**# Generate SSH Key Pairs**
53
+
54
+
Open a terminal window and enter the following command.
When prompted to `Enter file in which to save the key`, just hit `[ENTER]` on your keyboard to accept the location shown. If there are already keys in that location you'll be asked if you want to overwrite them. Hit `y` or `n` as appropriate.
61
+
62
+
You'll then be asked to `Enter passphrase` and to reconfirm it - choose a secure one - then hit `[ENTER]` after each prompt and the keys will be generated, along with your password and email as a label.
To avoid having to provide a password every time we connect to a service we can use the ssh-agent on our system. This agent handles passwords for ssh private keys and connections to the remote service we're logging into. This avoids having to send passwords over the network to the service.
69
+
70
+
Check if the ssh-agent running by typing the following command
71
+
72
+
```bash
73
+
eval"$(ssh-agent -s)"
74
+
```
75
+
This should return the PID for the ssh-agent which means it has been started in the background.
76
+
77
+

78
+
79
+
Now add the ssh keys to the ssh-agent by typing one of the following depending on your system.
80
+
```bash
81
+
Windows: ssh-add ~/.ssh/id_rsa
82
+
Mac: ssh-add -K ~/.ssh/id_rsa
83
+
```
84
+
> The -K option is Apple's version of `ssh-add` which adds the passphrase to your keychain for when you add the key to the ssh-agent
85
+
86
+
You can check what identities have been added to the ssh-agent by typing:
87
+
```bash
88
+
ssh-add -l
89
+
```
90
+
91
+
### aaaaaaa
92
+
.
29
93
30
-
An SSH key is used to identify trusted computers, without entering a password.
31
94
[Instructions on how to generate an SSH key](https://git-scm.com/book/en/v2/Git-on-the-Server-Generating-Your-SSH-Public-Key)
32
95
96
+
97
+
.
98
+
99
+
.
100
+
101
+
.
102
+
103
+
.
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+
.
150
+
151
+
.
152
+
33
153
This ends our _Set-up Git and GitHub_ lesson. Is there something you don't understand? Try and go through the provided resources with your coach. If you have any feedback or can think of ways to improve this tutorial [send us an email](mailto:[email protected]) and let us know.
0 commit comments