Difference between revisions of "Git/C2/Basic-commands-of-Git/English-timed"
From Script | Spoken-Tutorial
PoojaMoolya (Talk | contribs) |
PoojaMoolya (Talk | contribs) |
||
(6 intermediate revisions by one other user not shown) | |||
Line 6: | Line 6: | ||
|- | |- | ||
|00:01 | |00:01 | ||
− | |Welcome to the spoken tutorial on''' Basic commands of Git'''. | + | |Welcome to the '''spoken tutorial''' on''' Basic commands of Git'''. |
|- | |- | ||
|00:05 | |00:05 | ||
− | |In this tutorial, we will learn about | + | |In this tutorial, we will learn about '''Git repository''' and some basic '''command'''s of '''Git'''. |
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
|00:13 | |00:13 | ||
− | |For this tutorial, I am using | + | |For this tutorial, I am using: |
− | + | '''Ubuntu Linux''' 14.04 | |
− | + | '''Git''' 2.3.2. and | |
− | + | ''''gedit' Text Editor'''. | |
− | + | ||
|- | |- | ||
|00:23 | |00:23 | ||
− | |You can use any editor of your choice. | + | |You can use any '''editor''' of your choice. |
|- | |- | ||
|00:27 | |00:27 | ||
− | |To follow this tutorial | + | |To follow this tutorial, you must have knowledge of running '''Linux '''commands on the '''Terminal.''' |
− | + | ||
|- | |- | ||
Line 38: | Line 33: | ||
|- | |- | ||
|00:40 | |00:40 | ||
− | |Now we will see what is '''Git repository.''' | + | |Now, we will see what is '''Git repository.''' |
|- | |- | ||
Line 46: | Line 41: | ||
|- | |- | ||
|00:50 | |00:50 | ||
− | | It can be located on the local machine or on a remote machine | + | | It can be located on the local machine or on a remote machine. |
|- | |- | ||
|00:55 | |00:55 | ||
− | | The difference between normal folder and a '''Git repository '''is | + | | The difference between normal folder and a '''Git repository '''is- |
|- | |- | ||
|01:00 | |01:00 | ||
− | | | + | | normal folder contains only files and directories |
|- | |- | ||
|01:04 | |01:04 | ||
− | | | + | |but the '''Git repository '''contains set of files and directories along with their complete history. |
|- | |- | ||
|01:11 | |01:11 | ||
− | |Now let us learn to create a '''Git repository''' in our local machine. | + | |Now, let us learn to create a '''Git repository''' in our local machine. |
|- | |- | ||
|01:17 | |01:17 | ||
− | |Press '''Ctrl+Alt+T | + | |Press '''Ctrl+Alt+T'''keys to open the terminal. |
|- | |- | ||
|01:22 | |01:22 | ||
− | |On my machine, I will create a '''directory''' for the '''Git repository | + | |On my machine, I will create a '''directory''' for the '''Git repository '''in my '''Home''' directory. |
|- | |- | ||
Line 82: | Line 77: | ||
|- | |- | ||
|01:37 | |01:37 | ||
− | | Type | + | | Type: '''mkdir space mywebpage''' and press''' Enter'''. |
|- | |- | ||
|01:44 | |01:44 | ||
− | | So | + | | So, now we have created a directory "mywebpage" in our '''Home''' directory. |
|- | |- | ||
|01:49 | |01:49 | ||
− | |To go into this '''directory''', type | + | |To go into this '''directory''', type: '''cd space mywebpage''' and press''' Enter'''. |
|- | |- | ||
|02:00 | |02:00 | ||
− | |To make | + | |To make "mywebpage" directory as the '''Git repository''', type: '''git space init''' and press''' Enter'''. |
|- | |- | ||
|02:08 | |02:08 | ||
− | |You can see the message | + | |You can see the message “Initialized empty Git repository”. |
|- | |- | ||
|02:13 | |02:13 | ||
− | | This indicates that '''Git '''is initialized successfully | + | | This indicates that '''Git '''is initialized successfully |
|- | |- | ||
|02:17 | |02:17 | ||
− | | | + | |and this is the path where '''Git repository''' is created in our system. |
|- | |- | ||
Line 114: | Line 109: | ||
|- | |- | ||
|02:32 | |02:32 | ||
− | |To see the hidden folder, type '''ls space hyphen a''' and press''' Enter'''. | + | |To see the hidden folder, type: '''ls space hyphen a''' and press''' Enter'''. |
|- | |- | ||
Line 122: | Line 117: | ||
|- | |- | ||
|02:47 | |02:47 | ||
− | |So you should be very careful with this '''dot git''' folder. | + | |So, you should be very careful with this '''dot git''' folder. |
|- | |- | ||
|02:51 | |02:51 | ||
− | |Now we have to set our identity to '''Git'''. | + | |Now, we have to set our identity to '''Git'''. |
|- | |- | ||
|02:55 | |02:55 | ||
− | |To set the email address, type git space config space hyphen hyphen global space user dot email space priya[dot]spoken@gmail.com''' and press '''Enter''' | + | |To set the email address, type: '''git space config space hyphen hyphen global space user dot email space priya[dot]spoken@gmail.com''' and press '''Enter'''. |
|- | |- | ||
|03:12 | |03:12 | ||
− | |Here I have used '''<nowiki>priya[dot]spoken[at]gmail[dot]com</nowiki>''' | + | |Here, I have used '''<nowiki>priya[dot]spoken[at]gmail[dot]com</nowiki>'''. |
|- | |- | ||
Line 142: | Line 137: | ||
|- | |- | ||
|03:21 | |03:21 | ||
− | |To set the username, type '''git space config space hyphen hyphen global space user dot name space Priya''' and press '''Enter.''' | + | |To set the username, type: '''git space config space hyphen hyphen global space user dot name space Priya''' and press '''Enter.''' |
|- | |- | ||
|03:36 | |03:36 | ||
− | |I have used | + | |I have used "Priya" as a username. Please use your name instead of "Priya". |
|- | |- | ||
Line 154: | Line 149: | ||
|- | |- | ||
|03:51 | |03:51 | ||
− | |Next I will configure the '''gedit text editor''' to give the '''commit''' message. | + | |Next, I will configure the '''gedit text editor''' to give the '''commit''' message. |
|- | |- | ||
|03:57 | |03:57 | ||
− | | Type '''git space config space hyphen hyphen global space core dot editor space gedit''' and press '''Enter'''. | + | | Type: '''git space config space hyphen hyphen global space core dot editor space gedit''' and press '''Enter'''. |
|- | |- | ||
|04:09 | |04:09 | ||
− | | Now '''gedit''' is configured to '''Git'''. | + | | Now, '''gedit''' is configured to '''Git'''. |
|- | |- | ||
|04:14 | |04:14 | ||
− | |Here | + | |Here, 'global' '''flag''' is optional. |
|- | |- | ||
Line 182: | Line 177: | ||
|- | |- | ||
|04:34 | |04:34 | ||
− | |So, whenever you create a new '''Git repository,''' this setting will be applied | + | |So, whenever you create a new '''Git repository,''' this setting will be applied by default. |
|- | |- | ||
|04:42 | |04:42 | ||
− | | If you want the identity only for a particular repository | + | | If you want the identity only for a particular repository then do not use '''hyphen hyphen global''' flag. |
|- | |- | ||
Line 194: | Line 189: | ||
|- | |- | ||
|04:51 | |04:51 | ||
− | | Now let us check the configuration details of the identity that we set earlier. | + | | Now, let us check the configuration details of the identity that we set earlier. |
|- | |- | ||
|04:57 | |04:57 | ||
− | |Type '''git space config space hyphen hyphen list''' and press '''Enter.''' | + | |Type: '''git space config space hyphen hyphen list''' and press '''Enter.''' |
|- | |- | ||
|05:04 | |05:04 | ||
− | |Now, you can see the '''editor name, email address''' and username. | + | |Now, you can see the '''editor name, email address''' and '''username'''. |
|- | |- | ||
|05:10 | |05:10 | ||
− | |I will be using '' | + | |I will be using 'html' files for demonstration. |
|- | |- | ||
|05:14 | |05:14 | ||
− | |You can use any file type of your choice. For | + | |You can use any file type of your choice. For e.g. text files or doc files. |
|- | |- | ||
Line 218: | Line 213: | ||
|- | |- | ||
|05:26 | |05:26 | ||
− | |Now type '''gedit space mypage.html space ampersand'''. | + | |Now, type: '''gedit space mypage.html space ampersand'''. |
|- | |- | ||
|05:34 | |05:34 | ||
− | |If you are using another file | + | |If you are using another file then give that filename instead of "mypage.html". |
|- | |- | ||
|05:41 | |05:41 | ||
− | |We use the '' | + | |We use the '&' (ampersand) to free up the prompt. Now, press '''Enter'''. |
|- | |- | ||
|05:47 | |05:47 | ||
− | |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. |
|- | |- | ||
Line 238: | Line 233: | ||
|- | |- | ||
|05:58 | |05:58 | ||
− | |Now, I will save my file. | + | |Now, I will '''save''' my file. |
|- | |- | ||
Line 250: | Line 245: | ||
|- | |- | ||
|06:13 | |06:13 | ||
− | |Next, we will ask '''Git''' to follow the file | + | |Next, we will ask '''Git''' to follow the file "mypage.html". |
|- | |- | ||
|06:18 | |06:18 | ||
− | |Switch back to the | + | |Switch back to the terminal and type: '''git space add space mypage.html''' and press '''Enter'''. |
|- | |- | ||
|06:27 | |06:27 | ||
− | |Now we will check the current status of '''Git'''. So type '''git space status''' and press''' Enter'''. | + | |Now, we will check the current status of '''Git'''. So, type: '''git space status''' and press''' Enter'''. |
|- | |- | ||
|06:36 | |06:36 | ||
− | |You can see | + | |You can see “new file: mypage.html”. This means that '''Git '''has started following the changes made to this file "mypage.html". |
|- | |- | ||
|06:48 | |06:48 | ||
− | |This is called | + | |This is called '''tracking'''. |
|- | |- | ||
|06:51 | |06:51 | ||
− | |Let us switch back to our file''' mypage.html''' | + | |Let us switch back to our file''' mypage.html''' |
|- | |- | ||
|06:55 | |06:55 | ||
− | | | + | |and add a few more lines of code to this file. |
|- | |- | ||
Line 282: | Line 277: | ||
|- | |- | ||
|07:06 | |07:06 | ||
− | |Save and close the file. | + | |'''Save''' and close the file. |
|- | |- | ||
|07:10 | |07:10 | ||
− | |Then switch back to the | + | |Then switch back to the terminal. As before, to check the current status of '''Git''', type: '''git space status''' and press''' Enter'''. |
− | + | ||
− | '''git space status''' and press''' Enter'''. | + | |
|- | |- | ||
|07:21 | |07:21 | ||
− | |It shows | + | |It shows: “Changes not staged for commit:” and “modified: mypage.html”. |
|- | |- | ||
Line 300: | Line 293: | ||
|- | |- | ||
|07:34 | |07:34 | ||
− | |Let us switch back to our | + | |Let us switch back to our '''slide'''s to know more about '''Staging area'''. |
|- | |- | ||
Line 320: | Line 313: | ||
|- | |- | ||
|08:01 | |08:01 | ||
− | |Now, let us see how to add the new changes of the file | + | |Now, let us see how to add the new changes of the file to the''' staging area'''. |
|- | |- | ||
Line 328: | Line 321: | ||
|- | |- | ||
|08:11 | |08:11 | ||
− | | Type''' git space add space mypage dot html''' and press''' Enter'''. | + | | Type: '''git space add space mypage dot html''' and press''' Enter'''. |
|- | |- | ||
|08:19 | |08:19 | ||
− | |To check the | + | |To check the Git status, type: '''git space status''' and press''' Enter'''. |
|- | |- | ||
|08:26 | |08:26 | ||
− | |Now you can see the message | + | |Now you can see the message: “Changes to be committed:”. |
|- | |- | ||
Line 344: | Line 337: | ||
|- | |- | ||
|08:37 | |08:37 | ||
− | |Now we will freeze our code at this point. | + | |Now, we will '''freeze''' our code at this point. |
|- | |- | ||
|08:40 | |08:40 | ||
− | | When we attain a particular stage in our work, we can save them in the '''repository'''. This is called '''commit'''. | + | | When we attain a particular stage in our work, we can '''save''' them in the '''repository'''. This is called '''commit'''. |
|- | |- | ||
Line 356: | Line 349: | ||
|- | |- | ||
|08:57 | |08:57 | ||
− | |Now let us see how to '''commit'''. Switch back to the | + | |Now, let us see how to '''commit'''. Switch back to the terminal and type: '''git space commit''' and press '''Enter'''. |
|- | |- | ||
Line 364: | Line 357: | ||
|- | |- | ||
|09:13 | |09:13 | ||
− | |In the first line, I will type | + | |In the first line, I will type: “Initial commit” as the '''commit message'''. |
|- | |- | ||
Line 372: | Line 365: | ||
|- | |- | ||
|09:22 | |09:22 | ||
− | | Here you can see some lines begin with '''hash'''. You can leave them as it is or you can delete them. | + | | Here, you can see some lines begin with '''hash'''. You can leave them as it is or you can delete them. |
|- | |- | ||
|09:30 | |09:30 | ||
− | | Please write the '''commit''' | + | | Please write the '''commit message''' before or after the '''hash''' line. |
|- | |- | ||
Line 384: | Line 377: | ||
|- | |- | ||
|09:41 | |09:41 | ||
− | |Let me save and close the editor. | + | |Let me '''save''' and close the editor. |
|- | |- | ||
|09:44 | |09:44 | ||
− | |You will see some details, such as | + | |You will see some details, such as: |
− | + | The '''commit message''' | |
− | + | How many files we have changed | |
− | + | How many insertions we have done and | |
− | + | Name of the file. | |
− | + | ||
|- | |- | ||
|09:56 | |09:56 | ||
− | |Now let us see the '''commit''' details using '''git log''' command. | + | |Now, let us see the '''commit''' details using '''git log''' command. |
|- | |- | ||
|10:00 | |10:00 | ||
− | |Type''' git space log''' and press '''Enter.''' | + | |Type:''' git space log''' and press '''Enter.''' |
|- | |- | ||
Line 421: | Line 413: | ||
|- | |- | ||
|10:25 | |10:25 | ||
− | | | + | | Git stores all the information in its database by the '''hash value.''' |
|- | |- | ||
|10:31 | |10:31 | ||
− | | | + | | '''Git commit'''s are identified by the '''SHA-1 hash'''. |
|- | |- | ||
|10:35 | |10:35 | ||
− | | You will understand the importance of the '''SHA-1 hash '''in future tutorials | + | | You will understand the importance of the '''SHA-1 hash '''in future tutorials. |
|- | |- | ||
| 10:41 | | 10:41 | ||
− | |Let us come back to our | + | |Let us come back to our terminal. |
|- | |- | ||
|10:43 | |10:43 | ||
− | | It shows the details of the '''commit''' such as '''author name, email address, date, time''' and the '''commit message''' | + | | It shows the details of the '''commit''' such as '''author name, email address, date, time''' and the '''commit message''' which we gave earlier. |
|- | |- | ||
Line 445: | Line 437: | ||
|- | |- | ||
|11:00 | |11:00 | ||
− | |Let us summarize. In this tutorial we have learnt about | + | |Let us summarize. In this tutorial, we have learnt about: |
− | + | '''Git repository''' and | |
− | + | Some basic commands of '''Git''' like '''git init, status, commit '''and''' log'''. | |
− | + | ||
|- | |- | ||
|11:14 | |11:14 | ||
− | |As an assignment | + | |As an assignment- Create a '''directory''' in your machine and make it as a '''repository'''. |
|- | |- | ||
Line 472: | Line 463: | ||
|- | |- | ||
|11:35 | |11:35 | ||
− | | The video at the following link | + | | The video at the following link summarizes the Spoken Tutorial project. Please download and watch it. |
|- | |- | ||
|11:43 | |11:43 | ||
− | | The Spoken Tutorial Project | + | | The Spoken Tutorial Project team conducts workshops and gives certificates to those who pass online tests. For more details, please write to us. |
|- | |- | ||
Line 484: | Line 475: | ||
|- | |- | ||
|12:02 | |12:02 | ||
− | | More information on this | + | | More information on this mission is available at the following link. |
|- | |- | ||
|12:08 | |12:08 | ||
− | |This is Priya from IIT Bombay. Thanks for joining. | + | |This is Priya from '''IIT Bombay'''. Thanks for joining. |
|} | |} |
Latest revision as of 19:02, 20 February 2017
00:01 | Welcome to the spoken tutorial on Basic commands of Git. |
00:05 | In this tutorial, we will learn about Git repository and some basic commands of Git. |
00:13 | For this tutorial, I am using:
Ubuntu Linux 14.04 Git 2.3.2. and 'gedit' Text Editor. |
00:23 | You can use any editor of your choice. |
00:27 | To follow this tutorial, you must have knowledge of running Linux commands on the Terminal. |
00:34 | If not, for relevant Linux tutorials, please visit our website. |
00:40 | Now, we will see what is Git repository. |
00:44 | Git repository is a folder where all the data of our project will be stored. |
00:50 | It can be located on the local machine or on a remote machine. |
00:55 | The difference between normal folder and a Git repository is- |
01:00 | normal folder contains only files and directories |
01:04 | but the Git repository contains set of files and directories along with their complete history. |
01:11 | Now, let us learn to create a Git repository in our local machine. |
01:17 | Press Ctrl+Alt+Tkeys to open the terminal. |
01:22 | On my machine, I will create a directory for the Git repository in my Home directory. |
01:28 | You can create the directory wherever you want on your machine. |
01:33 | By default, we are in our Home directory. |
01:37 | Type: mkdir space mywebpage and press Enter. |
01:44 | So, now we have created a directory "mywebpage" in our Home directory. |
01:49 | To go into this directory, type: cd space mywebpage and press Enter. |
02:00 | To make "mywebpage" directory as the Git repository, type: git space init and press Enter. |
02:08 | You can see the message “Initialized empty Git repository”. |
02:13 | This indicates that Git is initialized successfully |
02:17 | and this is the path where Git repository is created in our system. |
02:24 | After initialization, a hidden folder dot git will be created inside the mywebpage folder. |
02:32 | To see the hidden folder, type: ls space hyphen a and press Enter. |
02:39 | It shows the dot git folder. Deleting this dot git folder will delete the whole repository. |
02:47 | So, you should be very careful with this dot git folder. |
02:51 | Now, we have to set our identity to Git. |
02:55 | To set the email address, type: git space config space hyphen hyphen global space user dot email space priya[dot]spoken@gmail.com and press Enter. |
03:12 | Here, I have used priya[dot]spoken[at]gmail[dot]com. |
03:18 | You can use your own valid email address. |
03:21 | To set the username, type: git space config space hyphen hyphen global space user dot name space Priya and press Enter. |
03:36 | I have used "Priya" as a username. Please use your name instead of "Priya". |
03:43 | The name and the email address that we set are the identities of the person who is working on Git. |
03:51 | Next, I will configure the gedit text editor to give the commit message. |
03:57 | Type: git space config space hyphen hyphen global space core dot editor space gedit and press Enter. |
04:09 | Now, gedit is configured to Git. |
04:14 | Here, 'global' flag is optional. |
04:17 | We will switch back to our slides to know more about global flag. |
04:22 | Multiple repositories can be created in a single machine. |
04:26 | If you use hyphen hyphen global flag, the setting will be applied to all the repositories in the machine. |
04:34 | So, whenever you create a new Git repository, this setting will be applied by default. |
04:42 | If you want the identity only for a particular repository then do not use hyphen hyphen global flag. |
04:49 | Switch back to the terminal. |
04:51 | Now, let us check the configuration details of the identity that we set earlier. |
04:57 | Type: git space config space hyphen hyphen list and press Enter. |
05:04 | Now, you can see the editor name, email address and username. |
05:10 | I will be using 'html' files for demonstration. |
05:14 | You can use any file type of your choice. For e.g. text files or doc files. |
05:22 | Switch back to the terminal. Let me clear the prompt. |
05:26 | Now, type: gedit space mypage.html space ampersand. |
05:34 | If you are using another file then give that filename instead of "mypage.html". |
05:41 | We use the '&' (ampersand) to free up the prompt. Now, press Enter. |
05:47 | I will copy and paste some code into this file, from my Writer document, which I had saved earlier. |
05:54 | Likewise, add some content into your file. |
05:58 | Now, I will save my file. |
06:00 | So, I have an html file with some code in it. |
06:05 | Note: wherever I use mypage.html, you will have to replace it with your filename. |
06:13 | Next, we will ask Git to follow the file "mypage.html". |
06:18 | Switch back to the terminal and type: git space add space mypage.html and press Enter. |
06:27 | Now, we will check the current status of Git. So, type: git space status and press Enter. |
06:36 | You can see “new file: mypage.html”. This means that Git has started following the changes made to this file "mypage.html". |
06:48 | This is called tracking. |
06:51 | Let us switch back to our file mypage.html |
06:55 | and add a few more lines of code to this file. |
06:58 | Like before, I will copy-paste from my Writer file. |
07:06 | Save and close the file. |
07:10 | Then switch back to the terminal. As before, to check the current status of Git, type: git space status and press Enter. |
07:21 | It shows: “Changes not staged for commit:” and “modified: mypage.html”. |
07:28 | This means that the changes we made, have not been added to the staging area. |
07:34 | Let us switch back to our slides to know more about Staging area. |
07:39 | Staging area is a file that stores information of the changes that need to be committed. |
07:46 | The file contents should be added to the staging area before committing them. |
07:51 | We will discuss more about commit in the upcoming tutorials. |
07:56 | Older Git versions used the term index instead of staging area. |
08:01 | Now, let us see how to add the new changes of the file to the staging area. |
08:07 | Switch back to the terminal. Let me clear the prompt. |
08:11 | Type: git space add space mypage dot html and press Enter. |
08:19 | To check the Git status, type: git space status and press Enter. |
08:26 | Now you can see the message: “Changes to be committed:”. |
08:30 | This means that the file has been added to the staging area and is ready to be committed. |
08:37 | Now, we will freeze our code at this point. |
08:40 | When we attain a particular stage in our work, we can save them in the repository. This is called commit. |
08:49 | Each commit is saved with the information of username, email-id, date, time and commit message. |
08:57 | Now, let us see how to commit. Switch back to the terminal and type: git space commit and press Enter. |
09:07 | gedit text editor opens up automatically to get the commit message. |
09:13 | In the first line, I will type: “Initial commit” as the commit message. |
09:18 | You can type any informative message that you want. |
09:22 | Here, you can see some lines begin with hash. You can leave them as it is or you can delete them. |
09:30 | Please write the commit message before or after the hash line. |
09:35 | In future, with this commit message, we can identify what we did till this stage. |
09:41 | Let me save and close the editor. |
09:44 | You will see some details, such as:
The commit message How many files we have changed How many insertions we have done and Name of the file. |
09:56 | Now, let us see the commit details using git log command. |
10:00 | Type: git space log and press Enter. |
10:06 | We have only one commit in our repository. |
10:09 | It shows a unique ID which is called commit hash or SHA-1 hash. |
10:16 | Switch back to our slides to know more about SHA-1 hash. |
10:20 | SHA-1 hash is a unique id of 40 alpha-numeric characters. |
10:25 | Git stores all the information in its database by the hash value. |
10:31 | Git commits are identified by the SHA-1 hash. |
10:35 | You will understand the importance of the SHA-1 hash in future tutorials. |
10:41 | Let us come back to our terminal. |
10:43 | It shows the details of the commit such as author name, email address, date, time and the commit message which we gave earlier. |
10:56 | With this, we come to the end of this tutorial. |
11:00 | Let us summarize. In this tutorial, we have learnt about:
Git repository and Some basic commands of Git like git init, status, commit and log. |
11:14 | As an assignment- Create a directory in your machine and make it as a repository. |
11:20 | Create a text file and add some content into it. |
11:25 | Add the file to the staging area of the Git repository. |
11:29 | Commit the file to your repository and |
11:32 | See the commit details using git log command. |
11:35 | The video at the following link summarizes the Spoken Tutorial project. Please download and watch it. |
11:43 | The Spoken Tutorial Project team conducts workshops and gives certificates to those who pass online tests. For more details, please write to us. |
11:55 | Spoken Tutorial Project is funded by NMEICT, MHRD, Government of India. |
12:02 | More information on this mission is available at the following link. |
12:08 | This is Priya from IIT Bombay. Thanks for joining. |