Git/C2/Basic-commands-of-Git/English-timed
From Script | Spoken-Tutorial
Revision as of 12:27, 31 March 2016 by PoojaMoolya (Talk | contribs)
00:01 | Welcome to the spoken tutorial on Basic commands of Git. |
00:05 | In this tutorial, we will learn about
|
00:13 | For this tutorial, I am using
|
00:23 | You can use any editor of your choice. |
00:27 | To follow this tutorial
|
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+T keys 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 eg: 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
|
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 informations 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
|
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 summarises the Spoken Tutorial project.Pls 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. |