Skip to content

Commit 2527f32

Browse files
committed
Merge pull request #152 from steverob/patch-1
updated git tutorial
2 parents 0133a3c + abb91e0 commit 2527f32

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

version-control/command-line/tutorial.md

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ layout: page
33
title: Introduction to the git command line
44
---
55

6-
## Introduction to the git command line
6+
## Introduction to the Git command line
77

88
**PREREQUISITE:** Basic understanding of the command line.
99

1010
Git is an easy to share and collaborate tool that keeps our code tracked and safe.
1111
With the following examples we understand how to deal with the daily usage of the tool.
1212

1313
## Before you begin
14-
Install command line git for [OS X](http://code.google.com/p/git-osx-installer) or [Windows](http://msysgit.github.com/) and open your terminal. If you are on linux you should already have git installed.
14+
Install command line git for your operating system ([OS X](http://code.google.com/p/git-osx-installer), [Windows](http://msysgit.github.com/) or [Linux](http://git-scm.com/download/linux)) and open your terminal / command prompt.
1515

1616
Create a directory where you will be storing all your projects. You can call it `code` or `projects`.
1717

@@ -41,17 +41,19 @@ $ git init
4141
### Create a file
4242

4343
```bash
44-
$ echo "Learning git" > index.html
44+
$ echo "<h1>Learning git</h1>" > index.html
4545
```
4646

47-
> The above command will output `<h1>Learning git</h1>` and store it in index.html. Open up the file and have a look.
47+
> The above command will output `<h1>Learning git</h1>` and store it in `index.html`. Open up the file and have a look.
4848
4949
### Check the git repository status.
5050

5151
```bash
5252
$ git status
5353
```
5454

55+
> The above command will tell you what files in the current directory have been changed, what files have not yet been added to the git repository and so on.
56+
5557
### Add your file on the repository and commit your changes.
5658

5759
```bash
@@ -60,15 +62,15 @@ $ git status
6062
$ git commit -m 'this is my first command-line commit!'
6163
```
6264

63-
> . will add all the files in the current directory and subdirectories. You should only use it when initialising your repository, or you can specify the file name.
65+
> `.` will add all the files in the current directory and subdirectories. You should only use it when initialising your repository. Rest of the time you can specify the file names to be added.
6466
6567
### Check the git commit history.
6668

6769
```bash
6870
$ git log
6971
```
7072

71-
### Transferring project repository to online service
73+
### Transferring project repository to an online service
7274

7375
First you need to create an account to the service of your choice ([GitHub](http://github.com/join), [GitLab](http://gitlab.com)). Then, create a new project (or repository).
7476

@@ -82,9 +84,9 @@ $ git push -u origin master
8284

8385
#### What is `remote`
8486

85-
`remote` git all the remote repositories you have configured. You could have the same repository stored in many resources like GitHub and GitLab or Heroku.
87+
`remote` is simply the URL of your repository in any online repository hosting services. The `git remote` lists all the remote repositories you have configured. You could have the same repository stored in many places like GitHub and GitLab or Heroku and in such cases you will have a remote configured for each of the remote repository you have.
8688

87-
The structure of the command is `git remote <add|remove> <name of remote> <url of remote>`
89+
The structure of the command to add a new `remote` is `git remote <add|remove> <name of remote> <url of remote>`.
8890

8991
#### List all your remote repositories
9092

@@ -103,7 +105,7 @@ Username for 'https://github.com': <your username>
103105
Password for 'https://<username>@github.com': <your password>
104106
```
105107

106-
> When you are working with remote repo is important to sync your local repo before any commit, merge or push.
108+
> When you are working with a remote repo it is important to sync your local repo before doing any commit, merge or push.
107109
108110
### Syncing the remote copy with your local copy
109111

@@ -114,7 +116,7 @@ $ git log
114116

115117
# Example 2: Working with a remote service
116118

117-
Update the index.html file and then commit and push the changes
119+
Update the `index.html` file and then commit and push the changes
118120

119121
```html
120122
<html>
@@ -128,7 +130,7 @@ Update the index.html file and then commit and push the changes
128130
<dt>Initialise a git repository</dt>
129131
<dd>git init</dd>
130132
<dt>Add files to git</dt>
131-
<dd>git add <filename></dd>
133+
<dd>git add filename</dd>
132134
</dl>
133135
</body>
134136
</html>
@@ -161,7 +163,7 @@ $ git log
161163

162164
# Example 3: Verifying changes before any commit
163165

164-
Edit index.html
166+
Update `index.html`
165167

166168

167169
```html
@@ -194,7 +196,7 @@ $ git diff
194196
The -/+ indications you can see mean
195197

196198
**-** indicates lines removed from the code.
197-
199+
198200
**+** indicates lines added to the code.
199201

200202
```bash
@@ -230,7 +232,7 @@ Edit the index.html file and then check the changes.
230232
$ echo "oh no!" > index.html
231233
```
232234

233-
> Have a look at the file using `git diff`
235+
> Have a look at changes to the file using `git diff`
234236
235237
### Check the status of the repository
236238

@@ -250,7 +252,7 @@ no changes added to commit (use "git add" and/or "git commit -a")
250252
### To discard the changes checkout the file
251253

252254
```bash
253-
$ git checkout -- index.html
255+
$ git checkout index.html
254256
```
255257

256258
Don't forget to verify the changes
@@ -268,7 +270,7 @@ Repeat the steps below to change and commit a file
268270
$ echo "oh not again" > index.html
269271
$ git diff
270272
$ git add index.html
271-
$ git commit -am 'Oops, I just deleted my list'
273+
$ git commit -m 'Oops, I just deleted my list'
272274
```
273275

274276
> Can you explain the commands you just used?
@@ -304,7 +306,7 @@ Unstaged changes after reset:
304306
M index.html
305307
```
306308

307-
> The caret (^) after HEAD moves head back through commits. HEAD^ is short for HEAD^1 and in the same way you can apply HEAD^2 to go back two commit ago.
309+
> The caret (^) after HEAD moves head back through commits. HEAD^ is short for HEAD^1 and in the same way you can apply HEAD^2 to go back two commits ago.
308310
309311
### Check the log again
310312

@@ -339,7 +341,9 @@ $ git status
339341
$ git log
340342
```
341343

342-
> What does git push do?
344+
> `git commit -am 'commit message` is short form for `git add .` followed by `git commit -m 'message'`.
345+
346+
> What does `git push` do?
343347
344348
### Reverting a commit
345349

@@ -378,8 +382,7 @@ git push origin master
378382

379383
# Extras
380384

381-
If you are on OS X, check the following resources
382-
385+
Following are some good resources to to help you set up git.
383386
https://help.github.com/articles/set-up-git
384387

385388
## Configuring your git environment
@@ -430,7 +433,7 @@ To apply this you need to create a .gitignore file in your root path. There you
430433
> Do you know what these files are? You normally wouldn't want to commit logs or packages.
431434
432435

433-
### Pimping your log history
436+
### Pimping your log historyr
434437

435438
In your aliases add this as an alias for viewing git logs
436439
```

0 commit comments

Comments
 (0)