Difference between revisions of "Git/C2/Branching-in-Git/English-timed"
From Script | Spoken-Tutorial
PoojaMoolya (Talk | contribs) |
Sandhya.np14 (Talk | contribs) |
||
Line 5: | Line 5: | ||
|- | |- | ||
| 00:01 | | 00:01 | ||
− | | Welcome to the spoken tutorial on''' Branching in Git'''. | + | | Welcome to the '''spoken tutorial''' on''' Branching in Git'''. |
|- | |- | ||
| 00:05 | | 00:05 | ||
− | | In this tutorial, we will learn about | + | | In this tutorial, we will learn about: |
* '''Branching''' | * '''Branching''' | ||
* Creating a '''branch''' and | * Creating a '''branch''' and | ||
− | * Switching between '''branches''' | + | * Switching between '''branches'''. |
|- | |- | ||
| 00:15 | | 00:15 | ||
− | | 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'''. |
|- | |- | ||
| 00:25 | | 00:25 | ||
− | | You can use any editor of your choice. | + | | You can use any '''editor''' of your choice. |
|- | |- | ||
| 00:29 | | 00:29 | ||
− | | To follow this tutorial you must have knowledge of running''' Linux''' commands on''' Terminal'''. | + | | To follow this tutorial, you must have knowledge of running''' Linux''' commands on''' Terminal'''. |
|- | |- | ||
Line 39: | Line 39: | ||
|- | |- | ||
| 00:44 | | 00:44 | ||
− | | Typically, '''branches''' are used in a project to develop new modules or to fix a bug. | + | | Typically, '''branches''' are used in a project to develop new modules or to fix a '''bug'''. |
|- | |- | ||
Line 55: | Line 55: | ||
|- | |- | ||
| 01:06 | | 01:06 | ||
− | | | + | | and it would be merged with the''' master''' '''branch''' later. |
|- | |- | ||
Line 67: | Line 67: | ||
|- | |- | ||
| 01:25 | | 01:25 | ||
− | | Then a '''branch new-module''' is created in '''C3''' '''commit'''. | + | | Then a '''branch 'new-module'''' is created in '''C3''' '''commit'''. |
|- | |- | ||
Line 79: | Line 79: | ||
|- | |- | ||
| 01:43 | | 01:43 | ||
− | | Here you can see that''' new-module''' '''branch''' is not disturbing the''' master''' '''branch'''. | + | | Here, you can see that''' new-module''' '''branch''' is not disturbing the''' master''' '''branch'''. |
|- | |- | ||
Line 99: | Line 99: | ||
|- | |- | ||
| 02:13 | | 02:13 | ||
− | | Type''' cd space mywebpage''' and press''' Enter'''. | + | | Type:''' cd space mywebpage''' and press''' Enter'''. |
|- | |- | ||
Line 115: | Line 115: | ||
|- | |- | ||
| 02:43 | | 02:43 | ||
− | | Type''' git space branch''' and press''' Enter'''. | + | | Type:''' git space branch''' and press''' Enter'''. |
|- | |- | ||
| 02:48 | | 02:48 | ||
− | | It shows the default '''branch master,''' as mentioned earlier. | + | | It shows the default '''branch 'master',''' as mentioned earlier. |
|- | |- | ||
| 02:53 | | 02:53 | ||
− | | Now say, I want to create a '''branch''' named | + | | Now say, I want to create a '''branch''' named "new-chapter". |
|- | |- | ||
| 02:57 | | 02:57 | ||
− | | Type''' git space branch space new-chapter''' and press''' Enter'''. | + | | Type:''' git space branch space new-chapter''' and press''' Enter'''. |
|- | |- | ||
| 03:04 | | 03:04 | ||
− | | Let us see the '''branch''' | + | | Let us see the '''branch list''' by typing''' git space branch''' and press''' Enter'''. |
|- | |- | ||
| 03:12 | | 03:12 | ||
− | | Here we can see the '''branch | + | | Here, we can see the '''branch''' "new-chapter" in the list. |
|- | |- | ||
| 03:16 | | 03:16 | ||
− | | We can also see an | + | | We can also see an asterisk symbol with the''' master branch'''. |
|- | |- | ||
| 03:20 | | 03:20 | ||
− | | It indicates that currently we are working in the''' master | + | | It indicates that currently we are working in the''' master branch'''. |
|- | |- | ||
| 03:25 | | 03:25 | ||
− | | To go into the | + | | To go into the "new-chapter" '''branch''', type:''' git space checkout space new-chapter''' and press''' Enter'''. |
|- | |- | ||
| 03:36 | | 03:36 | ||
− | | To check the '''branch''' name, type''' git space branch''' and press''' Enter'''. | + | | To check the '''branch''' name, type:''' git space branch''' and press''' Enter'''. |
|- | |- | ||
| 03:42 | | 03:42 | ||
− | | By seeing the | + | | By seeing the asterisk, we can understand that now we are in the "new-chapter" '''branch'''. |
|- | |- | ||
Line 163: | Line 163: | ||
|- | |- | ||
| 03:57 | | 03:57 | ||
− | | Type | + | | Type:''' gedit space story.html space ampersand''' and press''' Enter'''. |
|- | |- | ||
| 04:05 | | 04:05 | ||
− | | I will copy and paste some code into this file, from my '''Writer''' document, which I had saved earlier. | + | | I will '''copy''' and '''paste''' some code into this file, from my '''Writer''' document, which I had saved earlier. |
|- | |- | ||
| 04:12 | | 04:12 | ||
− | | Save and close the file. | + | | '''Save''' and close the file. |
|- | |- | ||
Line 179: | Line 179: | ||
|- | |- | ||
| 04:21 | | 04:21 | ||
− | | To add the file to the '''staging area''', type '''git space add space story.html''' and press''' Enter'''. | + | | To add the file to the '''staging area''', type: '''git space add space story.html''' and press''' Enter'''. |
|- | |- | ||
| 04:31 | | 04:31 | ||
− | | To '''commit '''our work, type '''git space commit space hyphen m space''' within double quotes''' “Added story.html in new-chapter branch”''' and press''' Enter.''' | + | | To '''commit '''our work, type: '''git space commit space hyphen m space''' within double quotes''' “Added story.html in new-chapter branch”''' and press''' Enter.''' |
|- | |- | ||
| 04:47 | | 04:47 | ||
− | | Let’s check the''' Git log''' of | + | | Let’s check the''' Git log''' of "new-chapter" '''branch''' by typing''' git space log space hyphen hyphen oneline''' and press''' Enter'''. |
|- | |- | ||
| 04:57 | | 04:57 | ||
− | | Here we can see our latest '''commit''' | + | | Here, we can see our latest '''commit''' “Added story.html in new-chapter branch”. |
|- | |- | ||
| 05:04 | | 05:04 | ||
− | | Now, let’s say we want to go back to our''' master | + | | Now, let’s say, we want to go back to our''' master branch''' to do some work. |
|- | |- | ||
| 05:10 | | 05:10 | ||
− | | So we’ll type | + | | So, we’ll type:''' git space checkout space master''' and press''' Enter'''. |
|- | |- | ||
| 05:18 | | 05:18 | ||
− | | To check the '''Git log''', type''' git space log space hyphen hyphen oneline''' and press''' Enter'''. | + | | To check the '''Git log''', type:''' git space log space hyphen hyphen oneline''' and press''' Enter'''. |
|- | |- | ||
| 05:27 | | 05:27 | ||
− | | Here we can't see the '''commit''' | + | | Here, we can't see the '''commit''' “Added story.html in new-chapter branch”. |
|- | |- | ||
| 05:34 | | 05:34 | ||
− | | This is because, that '''commit''' belongs to | + | | This is because, that '''commit''' belongs to "new-chapter" '''branch''' only. |
|- | |- | ||
Line 219: | Line 219: | ||
|- | |- | ||
| 05:45 | | 05:45 | ||
− | | Here we can't see the file''' story.html''' also. | + | | Here, we can't see the file''' story.html''' also. |
|- | |- | ||
Line 227: | Line 227: | ||
|- | |- | ||
| 05:55 | | 05:55 | ||
− | | | + | | Let's open the file by typing''' gedit space history.html space ampersand''' and press''' Enter'''. |
|- | |- | ||
Line 235: | Line 235: | ||
|- | |- | ||
| 06:08 | | 06:08 | ||
− | | Save and close the file. | + | | '''Save''' and close the file. |
|- | |- | ||
Line 251: | Line 251: | ||
|- | |- | ||
| 06:36 | | 06:36 | ||
− | | To go into '''new-chapter''' '''branch''', type '''git space checkout space new-chapter''' | + | | To go into '''new-chapter''' '''branch''', type: '''git space checkout space new-chapter''' and press''' Enter'''. |
− | and press''' Enter'''. | + | |
|- | |- | ||
| 06:46 | | 06:46 | ||
− | | Let’s check the '''Git log '''by typing''' git space log space hyphen hyphen oneline''' and press''' Enter''' | + | | Let’s check the '''Git log '''by typing''' git space log space hyphen hyphen oneline''' and press''' Enter'''. |
|- | |- | ||
| 06:55 | | 06:55 | ||
− | | Here, we can't see the '''commit “Added chapter two in history.html”''' as that is in | + | | Here, we can't see the '''commit “Added chapter two in history.html”''' as that is in the '''master''' '''branch'''. |
|- | |- | ||
| 07:04 | | 07:04 | ||
− | | Let’s add some lines in our file''' story.html'''.Type ''' gedit space story.html space ampersand''' | + | | Let’s add some lines in our file''' story.html'''. Type: '''gedit space story.html space ampersand''' |
and press''' Enter'''. | and press''' Enter'''. | ||
Line 273: | Line 272: | ||
|- | |- | ||
| 07:20 | | 07:20 | ||
− | | Save and close the file. | + | | '''Save''' and close the file. |
|- | |- | ||
| 07:22 | | 07:22 | ||
− | | To check the''' Git status,''' type''' git space status''' and press''' Enter'''. | + | | To check the''' Git status,''' type:''' git space status''' and press''' Enter'''. |
|- | |- | ||
Line 289: | Line 288: | ||
|- | |- | ||
| 07:41 | | 07:41 | ||
− | | Let us try to go back to the''' master''' '''branch'''. Type''' git space checkout space master''' and press''' Enter'''. | + | | Let us try to go back to the''' master''' '''branch'''. Type:''' git space checkout space master''' and press''' Enter'''. |
|- | |- | ||
Line 297: | Line 296: | ||
|- | |- | ||
| 07:59 | | 07:59 | ||
− | | But | + | | But, what if I don't want to '''commit '''the changes, as they are not important at this stage? This can be done using '''stashing'''. |
− | This can be done using '''stashing'''. | + | |
|- | |- | ||
Line 310: | Line 308: | ||
|- | |- | ||
| 08:19 | | 08:19 | ||
− | | Type''' git space checkout space hyphen hyphen force space master''' and press''' Enter'''. | + | | Type:''' git space checkout space hyphen hyphen force space master''' and press''' Enter'''. |
|- | |- | ||
Line 318: | Line 316: | ||
|- | |- | ||
| 08:36 | | 08:36 | ||
− | | Type''' git space checkout space new-chapter''' and press''' Enter.''' | + | | Type:''' git space checkout space new-chapter''' and press''' Enter.''' |
|- | |- | ||
Line 327: | Line 325: | ||
| 08:54 | | 08:54 | ||
| Here we can see that our changes have been discarded. | | Here we can see that our changes have been discarded. | ||
− | |||
− | |||
Let us close the gedit. | Let us close the gedit. | ||
Line 345: | Line 341: | ||
|- | |- | ||
| 09:12 | | 09:12 | ||
− | | In this tutorial, we have learnt about | + | | In this tutorial, we have learnt about: |
− | + | ||
* '''Branching''' | * '''Branching''' | ||
* Creating a '''branch''' and | * Creating a '''branch''' and | ||
Line 353: | Line 348: | ||
|- | |- | ||
| 09:23 | | 09:23 | ||
− | | As an assignment Create a '''branch''' named | + | | As an assignment- Create a '''branch''' named "chapter-two". |
|- | |- | ||
Line 365: | Line 360: | ||
|- | |- | ||
| 09:33 | | 09:33 | ||
− | | Switch back to''' master''' '''branch'''. | + | | Switch back to the''' master''' '''branch'''. |
|- | |- | ||
| 09:36 | | 09:36 | ||
− | | Check the''' Git log''' and | + | | Check the''' Git log''' and understand that, in the''' master branch''', you can't see the '''commits''' of the "branch chapter-two". |
|- | |- | ||
| 09:44 | | 09:44 | ||
− | | The video at the following link | + | | The video at the following link summarizes the Spoken Tutorial project. Please download and watch it. |
|- | |- | ||
|09:52 | |09:52 | ||
− | | The Spoken Tutorial Project | + | | The Spoken Tutorial Project team conducts workshops and gives certificates to those who pass online tests. |
|- | |- | ||
Line 385: | Line 380: | ||
|- | |- | ||
| 10:03 | | 10:03 | ||
− | | Spoken Tutorial Project is funded by NMEICT, MHRD, Government of India. More information on this | + | | Spoken Tutorial Project is funded by NMEICT, MHRD, Government of India. More information on this mission is available at the following link. |
|- | |- | ||
| 10:15 | | 10:15 | ||
− | | This is Priya from IIT Bombay. Thanks for joining. | + | | This is Priya from '''IIT Bombay'''. Thanks for joining. |
|} | |} |
Revision as of 13:24, 13 April 2016
|
|
00:01 | Welcome to the spoken tutorial on Branching in Git. |
00:05 | In this tutorial, we will learn about:
|
00:15 | For this tutorial, I am using:
|
00:25 | You can use any editor of your choice. |
00:29 | To follow this tutorial, you must have knowledge of running Linux commands on Terminal. |
00:36 | If not, for relevant Linux tutorials, please visit our website. |
00:42 | Let us learn about branching. |
00:44 | Typically, branches are used in a project to develop new modules or to fix a bug. |
00:52 | It helps to work with new modules of a project without disturbing the main project. |
00:58 | The default branch of the Git is master. |
01:02 | We use different branches to develop new modules |
01:06 | and it would be merged with the master branch later. |
01:11 | For example, this diagram visualizes a repository with master and new-module branches. |
01:18 | There are some commits named C1, C2 and C3 in the master branch. |
01:25 | Then a branch 'new-module' is created in C3 commit. |
01:30 | C4, C5 and C8 are the commits of new-module branch. |
01:36 | At the same time, the commits C6 and C7 have been made in the master branch. |
01:43 | Here, you can see that new-module branch is not disturbing the master branch. |
01:49 | Once the new-module is ready, we will merge it back with the master branch. |
01:55 | In this tutorial, I will demonstrate how branch works. Merging will be covered in the next tutorial. |
02:03 | Press Ctrl+Alt+T to open the terminal. |
02:07 | We will open our Git repository mywebpage which we created earlier. |
02:13 | Type: cd space mywebpage and press Enter. |
02:19 | I will continue to use html files for demonstration. You may use any file type of your choice. |
02:28 | Let us check the Git log by typing git space log space hyphen hyphen oneline and press Enter. |
02:37 | First, we will check whether we have any branch in the repository. |
02:43 | Type: git space branch and press Enter. |
02:48 | It shows the default branch 'master', as mentioned earlier. |
02:53 | Now say, I want to create a branch named "new-chapter". |
02:57 | Type: git space branch space new-chapter and press Enter. |
03:04 | Let us see the branch list by typing git space branch and press Enter. |
03:12 | Here, we can see the branch "new-chapter" in the list. |
03:16 | We can also see an asterisk symbol with the master branch. |
03:20 | It indicates that currently we are working in the master branch. |
03:25 | To go into the "new-chapter" branch, type: git space checkout space new-chapter and press Enter. |
03:36 | To check the branch name, type: git space branch and press Enter. |
03:42 | By seeing the asterisk, we can understand that now we are in the "new-chapter" branch. |
03:49 | Next, I will create a html file story.html and commit it for demonstration purpose. |
03:57 | Type: gedit space story.html space ampersand and press Enter. |
04:05 | I will copy and paste some code into this file, from my Writer document, which I had saved earlier. |
04:12 | Save and close the file. |
04:15 | Remember, we have to commit our work whenever we add or remove any file. |
04:21 | To add the file to the staging area, type: git space add space story.html and press Enter. |
04:31 | To commit our work, type: git space commit space hyphen m space within double quotes “Added story.html in new-chapter branch” and press Enter. |
04:47 | Let’s check the Git log of "new-chapter" branch by typing git space log space hyphen hyphen oneline and press Enter. |
04:57 | Here, we can see our latest commit “Added story.html in new-chapter branch”. |
05:04 | Now, let’s say, we want to go back to our master branch to do some work. |
05:10 | So, we’ll type: git space checkout space master and press Enter. |
05:18 | To check the Git log, type: git space log space hyphen hyphen oneline and press Enter. |
05:27 | Here, we can't see the commit “Added story.html in new-chapter branch”. |
05:34 | This is because, that commit belongs to "new-chapter" branch only. |
05:39 | Let’s check the folder content by typing ls and press Enter. |
05:45 | Here, we can't see the file story.html also. |
05:49 | Next, we shall make some changes in the file history.html. |
05:55 | Let's open the file by typing gedit space history.html space ampersand and press Enter. |
06:05 | Let’s add some lines. |
06:08 | Save and close the file. |
06:10 | Let’s commit our work at this point by typing git space commit space hyphen am space within double quotes “Added chapter two in history.html” and press Enter. |
06:26 | Till now, we have been working with the master branch. |
06:30 | Now, let us check if this commit is reflected in new-chapter branch. |
06:36 | To go into new-chapter branch, type: git space checkout space new-chapter and press Enter. |
06:46 | Let’s check the Git log by typing git space log space hyphen hyphen oneline and press Enter. |
06:55 | Here, we can't see the commit “Added chapter two in history.html” as that is in the master branch. |
07:04 | Let’s add some lines in our file story.html. Type: gedit space story.html space ampersand
and press Enter. |
07:16 | I will add some lines from my Writer document. |
07:20 | Save and close the file. |
07:22 | To check the Git status, type: git space status and press Enter. |
07:29 | Note that we have not committed our work at this stage. |
07:33 | What do you think will happen if we try to switch branch without committing? This should lead to an error. |
07:41 | Let us try to go back to the master branch. Type: git space checkout space master and press Enter. |
07:51 | This error shows that we can't switch back to other branches without committing the changes. |
07:59 | But, what if I don't want to commit the changes, as they are not important at this stage? This can be done using stashing. |
08:08 | We will learn about stashing in the upcoming tutorials. |
08:13 | For now, we will forcefully exit this branch by using the hyphen hyphen force flag. |
08:19 | Type: git space checkout space hyphen hyphen force space master and press Enter. |
08:28 | Once again, we will go back to new-chapter branch, to check whether the changes are discarded or not. |
08:36 | Type: git space checkout space new-chapter and press Enter. |
08:42 | Let’s open the file story.html by typing gedit space story.html space ampersand and press Enter. |
08:54 | Here we can see that our changes have been discarded.
Let us close the gedit. |
09:01 | In the next tutorial, we will learn to merge this new-chapter branch with the master branch. |
09:07 | With this, we come to the end of this tutorial. |
09:11 | Let us summarize. |
09:12 | In this tutorial, we have learnt about:
|
09:23 | As an assignment- Create a branch named "chapter-two". |
09:28 | Go into the chapter-two branch. |
09:31 | Do some commits. |
09:33 | Switch back to the master branch. |
09:36 | Check the Git log and understand that, in the master branch, you can't see the commits of the "branch chapter-two". |
09:44 | The video at the following link summarizes the Spoken Tutorial project. Please download and watch it. |
09:52 | The Spoken Tutorial Project team conducts workshops and gives certificates to those who pass online tests. |
09:59 | For more details, please write to us. |
10:03 | Spoken Tutorial Project is funded by NMEICT, MHRD, Government of India. More information on this mission is available at the following link. |
10:15 | This is Priya from IIT Bombay. Thanks for joining. |