Difference between revisions of "Git/C2/Inspection-and-Comparison-of-Git/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
 
(3 intermediate revisions by 2 users not shown)
Line 11: Line 11:
 
| 00:06
 
| 00:06
 
| In this tutorial, we will learn about:
 
| In this tutorial, we will learn about:
* '''git diff'''
+
'''git diff'''
* '''git show'''
+
'''git show'''
* '''git blame''' and
+
'''git blame''' and
* '''git help''' commands.
+
'''git help''' commands.
  
 
|-
 
|-
 
| 00:17
 
| 00:17
 
| For this tutorial, I am using-
 
| For this tutorial, I am using-
* '''Ubuntu Linux 14.04'''
+
'''Ubuntu Linux 14.04'''
* '''Git 2.3.2''' and
+
'''Git 2.3.2''' and
* '''gedit Text Editor'''.
+
'''gedit Text Editor'''.
  
 
|-
 
|-
Line 69: Line 69:
 
|-
 
|-
 
| 01:32
 
| 01:32
| Type:''' gedit space history.html space ampersand''' and press''' Enter'''.
+
| Type:''' gedit space history.html space ampersand''' and press''' Enter'''.
  
 
|-
 
|-
Line 81: Line 81:
 
|-
 
|-
 
| 01:51
 
| 01:51
| Recall that we have to commit our work whenever we add or remove any file.
+
| Recall that we have to '''commit''' our work whenever we add or remove any file.
  
 
|-
 
|-
Line 97: Line 97:
 
|-
 
|-
 
| 02:28
 
| 02:28
| Currently, we have two commits in our '''repository'''.
+
| Currently, we have two '''commit'''s in our '''repository'''.
  
 
|-
 
|-
 
| 02:33
 
| 02:33
| Open the files '''mypage.html '''and '''history.html''', by typing '''gedit space mypage.html space history.html space ampersand'''
+
| Open the files '''mypage.html '''and '''history.html''' by typing '''gedit space mypage.html space history.html space ampersand'''
  
 
|-
 
|-
Line 112: Line 112:
  
 
|-
 
|-
|03:01
+
| 03:01
 
| Then '''save''' and '''close''' the files.
 
| Then '''save''' and '''close''' the files.
  
Line 133: Line 133:
 
|-
 
|-
 
| 03:35
 
| 03:35
| Type''' git space diff''' and press''' Enter'''.
+
| Type:''' git space diff''' and press''' Enter'''.
  
 
|-
 
|-
Line 145: Line 145:
 
|-
 
|-
 
| 03:51
 
| 03:51
| '''a slash history.html''' is the version of last commit. And it is represented by a minus sign.
+
| '''a slash history.html''' is the version of last commit. And, it is represented by a minus sign.
  
 
|-
 
|-
|04:00
+
| 04:00
| '''b slash history.html''' is the version of current state. And it is represented by a plus sign.
+
| '''b slash history.html''' is the version of current state. And, it is represented by a plus sign.
  
 
|-
 
|-
Line 157: Line 157:
 
|-
 
|-
 
| 04:15
 
| 04:15
| And the green color line with the plus sign is the new version.
+
| And, the green color line with the plus sign is the new version.
  
 
|-
 
|-
Line 169: Line 169:
 
|-
 
|-
 
| 04:28
 
| 04:28
| Also you can see the changes of the file'''mypage.html'''. Press '''down arrow '''key.  
+
| Also, you can see the changes of the file'''mypage.html'''. Press '''down arrow '''key.  
  
 
|-
 
|-
Line 176: Line 176:
  
 
|-
 
|-
|04:38
+
| 04:38
| Here the output is displayed in colors.
+
| Here, the output is displayed in colors.
  
 
|-
 
|-
 
| 04:42
 
| 04:42
| If we can’t see the lines with colors, type '''git space config space hyphen hyphen global space color dot ui space true''' and press''' Enter'''.
+
| If we can’t see the lines with colors, type: '''git space config space hyphen hyphen global space color dot ui space true''' and press''' Enter'''.
  
 
|-
 
|-
Line 189: Line 189:
 
|-
 
|-
 
| 05:03
 
| 05:03
| Type''' git space diff  and Press Enter. Now the output is displayed without colors.
+
| Type:''' git space diff''' and press '''Enter'''. Now, the output is displayed without colors.
  
 
|-
 
|-
 
| 05:13
 
| 05:13
| Next I will show you how to see the changes in a particular file.
+
| Next, I will show you how to see the changes in a particular file.
  
 
|-
 
|-
 
| 05:18
 
| 05:18
| Type''' git space diff space history.html''' and press''' Enter.'''
+
| Type:''' git space diff space history.html''' and press''' Enter.'''
  
 
|-
 
|-
 
| 05:25
 
| 05:25
| Here we can see the changes made in the file''' history.html''' only.
+
| Here, we can see the changes made in the file''' history.html''' only.
  
 
|-
 
|-
 
| 05:31
 
| 05:31
| Let us now add our files to the staging area. Type''' git space add space history.html space mypage.html '''and press''' Enter'''.
+
| Let us now add our files to the '''staging area'''. Type:''' git space add space history.html space mypage.html '''and press''' Enter'''.
  
 
|-
 
|-
Line 213: Line 213:
 
|-
 
|-
 
| 05:52
 
| 05:52
| This time we don’t get any output because our files have been added to the staging area.
+
| This time, we don’t get any output because our files have been added to the staging area.
  
 
|-
 
|-
 
| 05:59
 
| 05:59
| In such a case, we can type''' git space diff space hyphen hyphen staged''' and press''' Enter'''.
+
| In such a case, we can type:''' git space diff space hyphen hyphen staged''' and press''' Enter'''.
  
 
|-
 
|-
 
| 06:08
 
| 06:08
| Now we can see the same output just like the one we got in the''' git diff''' command.
+
| Now, we can see the same output just like the one we got in the''' git diff''' command.
  
 
|-
 
|-
Line 233: Line 233:
 
|-
 
|-
 
|06:28
 
|06:28
| First we will see the '''Git log '''by typing git space log space hyphen hyphen oneline'''  
+
| First we will see the '''Git log '''by typing '''git space log space hyphen hyphen oneline''' and press''' Enter'''.
and press''' Enter'''.
+
  
 
|-
 
|-
 
| 06:38
 
| 06:38
| Now say, I want to compare my current state with the''' Initial commit'''.
+
| Now, say, I want to compare my current state with the''' Initial commit'''.
  
 
|-
 
|-
 
| 06:43
 
| 06:43
| So type''' git space diff space,''' then copy and paste the''' commit hash''' of the''' Initial commit''' and press''' Enter'''.
+
| So, type:''' git space diff space''', then '''copy''' and '''paste''' the''' commit hash''' of the''' Initial commit''' and press''' Enter'''.
  
 
|-
 
|-
 
| 06:52
 
| 06:52
| Here we can see the difference.
+
| Here, we can see the difference.
  
 
|-
 
|-
Line 254: Line 253:
 
|-
 
|-
 
| 07:02
 
| 07:02
| In this way, using git diff command we can see all the changes in the modified files.
+
| In this way, using '''git diff''' command we can see all the changes in the modified files.
  
 
|-
 
|-
Line 262: Line 261:
 
|-
 
|-
 
|07:15
 
|07:15
| Let us freeze our work at this point.
+
| Let us '''freeze''' our work at this point.
  
 
|-
 
|-
 
| 07:19
 
| 07:19
| To commit, type '''git space commit space hyphen m space'''  within double quotes''' “Added colors”''' and press''' Enter'''.
+
| To commit, type: '''git space commit space hyphen m space'''  within double quotes''' “Added colors”''' and press''' Enter'''.
  
 
|-
 
|-
Line 278: Line 277:
 
|-
 
|-
 
| 07:44
 
| 07:44
| Type''' git space diff space''' then copy and paste the''' commit hash''' of '''Initial commit” space'''.
+
| Type:''' git space diff space''' then '''copy''' and '''paste''' the''' commit hash''' of '''“Initial commit” space'''.
 
Now, copy and paste the''' commit hash''' of “'''Added colors”''' and press''' Enter'''.
 
Now, copy and paste the''' commit hash''' of “'''Added colors”''' and press''' Enter'''.
  
Line 291: Line 290:
 
|-
 
|-
 
| 08:08
 
| 08:08
| Type''' git space diff space HEAD space HEAD tilde '''and press''' Enter'''.
+
| Type:''' git space diff space HEAD space HEAD tilde '''and press''' Enter'''.
  
 
|-
 
|-
 
| 08:16
 
| 08:16
| '''HEAD''' indicates the last revision which has the commit message''' “Added colors”'''.
+
| '''HEAD''' indicates the last revision which has the '''commit message''' “Added colors”.
  
 
|-
 
|-
 
| 08:22
 
| 08:22
| '''HEAD tilde''' indicates the second last revision which has the commit message''' “Added history.html”.'''
+
| '''HEAD tilde''' indicates the second last revision which has the '''commit message''' “Added history.html”.
  
 
|-
 
|-
Line 307: Line 306:
 
|-
 
|-
 
| 08:39
 
| 08:39
| Likewise, Latest minus 2 is '''HEAD tilde 2''', Latest minus 3 is '''HEAD tilde 3''' and so on.
+
| Likewise, latest minus 2 is '''HEAD tilde 2''', latest minus 3 is '''HEAD tilde 3''' and so on.
  
 
|-
 
|-
Line 318: Line 317:
  
 
|-
 
|-
|09:00
+
| 09:00
| Type''' git space show''' and press''' Enter'''.
+
| Type:''' git space show''' and press''' Enter'''.
  
 
|-
 
|-
Line 335: Line 334:
 
|-
 
|-
 
| 09:20
 
| 09:20
| Now, let’s see the '''Git log '''by typing''' ''' '''git space log space hyphen hyphen oneline'''  
+
| Now, let’s see the '''Git log '''by typing '''git space log space hyphen hyphen oneline''' and press''' Enter'''.
and press''' Enter'''.
+
  
 
|-
 
|-
 
| 09:30
 
| 09:30
| To see the details of the''' Initial commit''', type''' git space show space ''' Then copy and paste the commit hash of the''' Initial commit''' and press''' Enter'''.
+
| To see the details of the''' Initial commit''', type:''' git space show space '''. Then copy and paste the commit hash of the''' Initial commit''' and press''' Enter'''.
  
 
|-
 
|-
 
| 09:42
 
| 09:42
| Here you can see the details of the''' Initial commit'''.
+
| Here, you can see the details of the''' Initial commit'''.
  
 
|-
 
|-
Line 352: Line 350:
 
|-
 
|-
 
| 09:51
 
| 09:51
| Next let us learn how to see the entire history of a file.
+
| Next, let us learn how to see the entire history of a file.
  
 
|-
 
|-
 
| 09:56
 
| 09:56
| To see the entire history of''' mypage.html''', type''' git space blame space mypage.html''' and press''' Enter'''.
+
| To see the entire history of''' mypage.html''', type:''' git space blame space mypage.html''' and press''' Enter'''.
  
 
|-
 
|-
|10:07
+
| 10:07
| Here we can see the entire history of the file''' mypage.html''' i.e. from creation point upto current stage.
+
| Here, we can see the entire history of the file''' mypage.html''' i.e. from creation point up to current stage.
  
 
|-
 
|-
Line 372: Line 370:
 
|-
 
|-
 
| 10:27
 
| 10:27
| The syntax to get help, is as follows
+
| The syntax to get help, is as follows-
 
+
  
 
'''git help <verb> ''' OR
 
'''git help <verb> ''' OR
Line 383: Line 380:
 
|-
 
|-
 
| 10:40
 
| 10:40
| For example: '''git help show'''
+
| For example: '''git help show'''.
  
 
|-
 
|-
 
| 10:44
 
| 10:44
| Let me demonstrate this. Switch back to the '''terminal''' and type '''git space help space show'''  
+
| Let me demonstrate this. Switch back to the '''terminal''' and type: '''git space help space show''' and press''' Enter'''.
and press''' Enter'''.
+
  
 
|-
 
|-
 
| 10:55
 
| 10:55
| Here we can see the manual of''' show command'''.  
+
| Here, we can see the manual of''' show command'''.  
  
 
|-
 
|-
Line 400: Line 396:
 
|-
 
|-
 
| 11:03
 
| 11:03
| Let us summarize.
+
| Let us summarize.In this tutorial, we have learnt about:
 
+
'''git diff'''
|-
+
'''git show'''
| 11:04
+
'''git blame''' and
| In this tutorial, we have learnt about  
+
'''git help''' commands.
* git diff
+
* git show  
+
* git blame and
+
* git help commands
+
  
 
|-
 
|-
 
| 11:15
 
| 11:15
| As an assignment
+
| As an assignment, explore the following commands:
 
+
'''git reflog'''
Explore the following commands
+
'''git diff HEAD tilde HEAD'''
* git reflog
+
'''git show HEAD''' and
* git diff HEAD tilde HEAD
+
'''man git diff'''.
* git show HEAD and
+
* man git diff
+
  
 
|-
 
|-
 
| 11:29
 
| 11:29
| The video at the following link summarises the Spoken Tutorial project. Please download and watch it.
+
| The video at the following link summarizes the Spoken Tutorial project. Please download and watch it.
  
 
|-
 
|-
 
| 11:37
 
| 11:37
| The Spoken Tutorial Project Team conducts workshops and gives certificates to those who pass online tests. For more details, please write to us.
+
| The Spoken Tutorial Project team conducts workshops and gives certificates to those who pass online tests. For more details, please write to us.
  
 
|-
 
|-
Line 434: Line 424:
 
|-
 
|-
 
| 11:55
 
| 11:55
| More information on this Mission is available at the following link.
+
| More information on this mission is available at the following link.
  
 
|-
 
|-
 
| 12:00
 
| 12:00
| This is Priya from IIT Bombay. Thanks for joining.
+
| This is Priya from '''IIT Bombay'''. Thanks for joining.
  
 
|}
 
|}

Latest revision as of 19:51, 8 March 2017

Time
Narration
00:01 Welcome to the spoken tutorial on Inspection and comparison of Git.
00:06 In this tutorial, we will learn about:

git diff git show git blame and git help commands.

00:17 For this tutorial, I am using-

Ubuntu Linux 14.04 Git 2.3.2 and gedit Text Editor.

00:29 You can use any editor of your choice.
00:33 To follow this tutorial, you must have knowledge of running Linux commands on Terminal.
00:40 If not, for relevant Linux tutorials, please visit our website.
00:46 Let us begin with git diff command.
00:50 This command will show the changes of the current status of the files.
00:55 Now, I will show you how it works. Press Ctrl+Alt+T to open the terminal.
01:03 We will go into our Git repository mywebpage which we created earlier.
01:09 Type: cd space mywebpage and press Enter.
01:15 I will continue to use html files for demonstration.
01:20 You may use any file type of your choice.
01:24 First, I will create a html file history.html and commit it for demonstration purpose.
01:32 Type: gedit space history.html space ampersand and press Enter.
01:41 I will copy and paste some code into this file, from my Writer document, which I had saved earlier.
01:48 Let us save and close the file.
01:51 Recall that we have to commit our work whenever we add or remove any file.
01:58 To add the file to the staging area, type: git space add space history.html and press Enter.
02:08 To commit our work, type: git space commit space hyphen m space within double quotes “Added history.html” and press Enter.
02:21 Let's see the Git log by typing git space log and press Enter.
02:28 Currently, we have two commits in our repository.
02:33 Open the files mypage.html and history.html by typing gedit space mypage.html space history.html space ampersand
02:47 Here, mypage.html is the file which we created in the previous tutorial. Now, press Enter.
02:56 Let us add and delete some lines in these files.
03:01 Then save and close the files.
03:05 In certain situations, we may not remember what changes we have made in our files.
03:11 Let us check the Git status by typing git space status and press Enter.
03:19 It simply shows the modified file names. But we cannot get any other details.
03:26 We want to know the actual changes that have been made to these files. Let us see how to check it.
03:35 Type: git space diff and press Enter.
03:40 This command will compare the current state of the files with the latest commit.
03:46 Here you will see the two versions of the file history.html.
03:51 a slash history.html is the version of last commit. And, it is represented by a minus sign.
04:00 b slash history.html is the version of current state. And, it is represented by a plus sign.
04:09 So, here the red color line with the minus sign is the old version.
04:15 And, the green color line with the plus sign is the new version.
04:20 Press down arrow key to see more.
04:23 These are the lines which we added in the new version.
04:28 Also, you can see the changes of the filemypage.html. Press down arrow key.
04:35 Press q key to exit.
04:38 Here, the output is displayed in colors.
04:42 If we can’t see the lines with colors, type: git space config space hyphen hyphen global space color dot ui space true and press Enter.
04:57 If you don't want to see the colors, please use false instead of true in this command.
05:03 Type: git space diff and press Enter. Now, the output is displayed without colors.
05:13 Next, I will show you how to see the changes in a particular file.
05:18 Type: git space diff space history.html and press Enter.
05:25 Here, we can see the changes made in the file history.html only.
05:31 Let us now add our files to the staging area. Type: git space add space history.html space mypage.html and press Enter.
05:44 Let’s check the Git diff again by typing git space diff and press Enter.
05:52 This time, we don’t get any output because our files have been added to the staging area.
05:59 In such a case, we can type: git space diff space hyphen hyphen staged and press Enter.
06:08 Now, we can see the same output just like the one we got in the git diff command.
06:15 We can also use hyphen hyphen cached instead of hyphen hyphen staged to get the same result.
06:23 How can we compare the current state with any previous commit?
06:28 First we will see the Git log by typing git space log space hyphen hyphen oneline and press Enter.
06:38 Now, say, I want to compare my current state with the Initial commit.
06:43 So, type: git space diff space, then copy and paste the commit hash of the Initial commit and press Enter.
06:52 Here, we can see the difference.
06:55 In this manner, we can compare our current state with any previous commit in our repository.
07:02 In this way, using git diff command we can see all the changes in the modified files.
07:09 It will help us to make sure what exactly we have changed before committing.
07:15 Let us freeze our work at this point.
07:19 To commit, type: git space commit space hyphen m space within double quotes “Added colors” and press Enter.
07:30 Next, let us learn how to see the difference between two commits.
07:35 Let’s check the Git log by typing git space log space hyphen hyphen oneline and press Enter.
07:44 Type: git space diff space then copy and paste the commit hash of “Initial commit” space.

Now, copy and paste the commit hash of “Added colors” and press Enter.

07:58 The difference between the two given commits can now be seen.
08:03 Next, we will compare the last revision with the second last revision.
08:08 Type: git space diff space HEAD space HEAD tilde and press Enter.
08:16 HEAD indicates the last revision which has the commit message “Added colors”.
08:22 HEAD tilde indicates the second last revision which has the commit message “Added history.html”.
08:30 The latest revision is always HEAD. The latest minus 1 revision is always HEAD tilde.
08:39 Likewise, latest minus 2 is HEAD tilde 2, latest minus 3 is HEAD tilde 3 and so on.
08:50 Switch back to the terminal.
08:53 Let us now learn about git show command which helps to see the entire details of a commit.
09:00 Type: git space show and press Enter.
09:04 This command will show the details of latest commit in the repository.
09:10 It shows what changes have been made to the files along with the commit details.
09:16 This feature is helpful when we work collaboratively.
09:20 Now, let’s see the Git log by typing git space log space hyphen hyphen oneline and press Enter.
09:30 To see the details of the Initial commit, type: git space show space . Then copy and paste the commit hash of the Initial commit and press Enter.
09:42 Here, you can see the details of the Initial commit.
09:46 In this manner, we can see the details of any commit of our repository.
09:51 Next, let us learn how to see the entire history of a file.
09:56 To see the entire history of mypage.html, type: git space blame space mypage.html and press Enter.
10:07 Here, we can see the entire history of the file mypage.html i.e. from creation point up to current stage.
10:17 Likewise, you can see the full details of any file in your repository.
10:22 Lastly, we will see how to get help from Git.
10:27 The syntax to get help, is as follows-

git help <verb> OR

git <verb> hyphen hyphen help OR

man git <verb>

10:40 For example: git help show.
10:44 Let me demonstrate this. Switch back to the terminal and type: git space help space show and press Enter.
10:55 Here, we can see the manual of show command.
10:59 With this, we come to the end of this tutorial.
11:03 Let us summarize.In this tutorial, we have learnt about:

git diff git show git blame and git help commands.

11:15 As an assignment, explore the following commands:

git reflog git diff HEAD tilde HEAD git show HEAD and man git diff.

11:29 The video at the following link summarizes the Spoken Tutorial project. Please download and watch it.
11:37 The Spoken Tutorial Project team conducts workshops and gives certificates to those who pass online tests. For more details, please write to us.
11:48 Spoken Tutorial Project is funded by NMEICT, MHRD, Government of India.
11:55 More information on this mission is available at the following link.
12:00 This is Priya from IIT Bombay. Thanks for joining.

Contributors and Content Editors

PoojaMoolya, Sandhya.np14