Git/C2/Basic-commands-of-Git/English
Title of script: Basic commands of Git
Author: Priya K
Keywords: Video tutorial, Git repository, basic commands, staging area, SHA-1 hash
|
|
Slide 1:
|
Welcome to the spoken tutorial on Basic commands of Git. |
Slide 2:
|
In this tutorial, we will learn about
|
Slide 3:
|
For this tutorial, I am using
You can use any editor of your choice. |
Slide 4:
|
To follow this tutorial
|
Slide 5:
|
Now we will see what is Git repository.
|
Press Ctrl+Alt+T to open terminal | Now let us learn to create a Git repository in our local machine.
|
Type mkdir mywebpage and press Enter
|
On my machine, I will create a directory for the Git repository, in my Home directory.
|
By default, we are in our Home directory.
mkdir space mywebpage and press Enter.
| |
Type cd mywebpage >> press Enter. | To go into this directory, type,
cd space mywebpage and press Enter. |
Type git init >> press Enter | To make mywebpage directory as the Git repository, type git space init and press Enter. |
Highlight the message “Initialized empty Git repository”
|
You can see the message “Initialized empty Git repository”.
|
Highlight the path | And this is the path where Git repository is created in our system. |
After initialization, a hidden folder dot git will be created inside the mywebpage folder. | |
Type ls -a and press Enter | To see the hidden folder, type
ls space hyphen a and press Enter. |
Highlight the hidden files | It shows the dot git folder.
|
Now we have to set our identity to Git. | |
Type git config --global user.email priya.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 |
Highlight priya.spoken@gmail.com | Here I have used priya[dot]spoken[at]gmail[dot]com
|
Type git config --global user.name spoken and press Enter | To set the username, type
git space config space hyphen hyphen global space user dot name space Priya and press Enter. |
Highlight Priya | I have used Priya as a username.
|
Highlight the name and email address | The name and the email address that we set are the identities of the person who is working on Git. |
Type git config --global core.editor gedit and press Enter | Next I will configure the gedit text editor to give the commit message.
|
Highlight --global flag
|
Here global flag is optional.
|
Slide 6:
|
|
Switch back to our terminal
|
Switch back to the terminal.
|
Type git config --list and press Enter | Type git space config space hyphen hyphen list and press Enter. |
Highlight name, email address and editor | Now, you can see the editor name, email address and username.
|
Slide 7:
|
I will be using html files for demonstration.
For eg: text files or doc files. |
Switch back to the terminal
|
Switch back to the terminal. Let me clear the prompt.
gedit space mypage.html space ampersand.
|
Copy and paste the code into the file
|
I will copy and paste some code into this file, from my Writer document, which I had saved earlier.
|
Save the file | Now, I will save my file. |
So, I have an html file with some code in it.
| |
Switch back to the terminal >> Type git add mypage.html and press Enter | Switch back to the terminal and type
git space add space mypage.html and press Enter. |
Type git status >> press Enter | Now we will check the current status of Git.
|
Highlight the message “new file: mypage.html” | You can see “new file: mypage.html”.
|
Come to mypage.html file | Let us switch back to our file mypage.html. |
Add few lines | And add a few more lines of code to this file.
|
Save and close the file | Save and close the file. |
Switch back to the terminal
|
Then switch back to the terminal.
git space status and press Enter. |
Highlight the message “Changes not staged for commit” and “modified: mypage.html” | It shows “Changes not staged for commit” and “modified: mypage.html”.
|
<<PAUSE>> | |
Slide 8: | Let us switch back to our slides to know more about Staging area.
|
Switch back to the terminal
|
Now, let us see how to add the new changes of the file, to the staging area.
|
Type git status >> press Enter | To check the Git status, type git space status and press Enter. |
Highlight the message “Changes to be committed:” | Now you can see the message “Changes to be committed:”
|
Now we will freeze our code at this point. | |
Slide 9:
|
|
|
Now let us see how to commit.
|
gedit text editor opens up automatically to get the commit message. | |
Type Initial commit
|
In the first line, I will type “Initial commit” as the commit message.
|
Highlight Initial commit | In future, with this commit message, we can identify what we did till this stage. |
Save and close the gedit | Let me save and close the editor. |
Highlight Initial Commit , 1 file changed, 11 insertions(+), and mypage.html
|
You will see some details, such as
|
Now let us see the commit details using git log command. | |
Type git log >> press Enter | Type git space log and press Enter. |
|
We have only one commit in our repository.
|
Slide 10:
|
|
|
Let us come back to our terminal.
|
With this, we come to the end of this tutorial. | |
Slide 11:
|
Let us summarize.
In this tutorial we have learnt about
|
Slide 12:
|
As an assignment
|
Slide 13:
Acknowledgement |
The video at the following link summarises the Spoken Tutorial project.
|
Slide 14:
Acknowledgement
|
The Spoken Tutorial Project Team conducts workshops and gives certificates to those who pass online tests.
|
Slide 15:
Acknowledgement |
Spoken Tutorial Project is funded by NMEICT, MHRD, Government of India.
|
This is Priya from IIT Bombay.
|