Difference between revisions of "Git/C2/Inspection-and-Comparison-of-Git/English"
Nancyvarkey (Talk | contribs) |
|||
Line 251: | Line 251: | ||
|- | |- | ||
− | | style="border:1pt solid #000000;padding:0.097cm;"| Highlight the lines | + | | style="border:1pt solid #000000;padding:0.097cm;"| Type''' git diff''' Highlight the lines |
− | | style="border:1pt solid #000000;padding:0.097cm;"| Now the output is displayed without colors. | + | | style="border:1pt solid #000000;padding:0.097cm;"| Type''' git diff''' and press''' Enter'''. Now the output is displayed without colors. |
Latest revision as of 11:55, 30 November 2016
Title of script: Inspection and comparison of Git
Author: Priya K
Keywords: Video tutorial, git diff, git show, git help, git blame, HEAD, HEAD~, color.ui
|
|
Slide 1:
|
Welcome to the spoken tutorial on Inspection and comparison 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-
|
Let us begin with git diff command.
| |
Press Ctrl+Alt+T to open the terminal | Now I will show how it works.
|
Type cd mywebpage and press Enter | We will go into our Git repository mywebpage which we created earlier.
|
I will continue to use html files for demonstration.
| |
Type gedit history.html & and press Enter | First I will create a html file history.html and commit it for demonstration purpose.
and press Enter. |
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 and close the file | Let us save and close the file. |
Recall that we have to commit our work whenever we add or remove any file. | |
Type git add history.html and press Enter | To add the file to the staging area, type
git space add space history.html
|
Type git commit -m “Added history.html” and press Enter | To commit our work, type
git space commit space hyphen m space within double quotes “Added history.html”
|
Type git log and press Enter | Lets see the Git log by typing git space log and press Enter. |
Highlight the commits | Currently, we have two commits in our repository.
|
Type gedit mypage.html history.html &
|
Open the files mypage.html and history.html, by typing
|
Add and delete lines | Let us add and delete some lines in these files. |
Save and close the files | Then save and close the files. |
Type git status and press Enter
|
In certain situations, we may not remember what changes we have made in our files.
|
Highlight “modified: mypage.html history.html” | It simply shows the modified file names.
|
We want to know the actual changes that have been made to these files.
| |
Type git diff and press Enter | Type git space diff and press Enter. |
This command will compare the current state of the files with the latest commit. | |
Highlight a/history.html b/history .html | Here you will see the two versions of the file history.html. |
Highlight ---a/history .html | a slash history.html is the version of last commit.
And it is represented by a minus sign. |
Highlight +++b/history .html | b slash history.html is the version of current state.
And it is represented by a plus sign. |
Highlight -<body> | So, here the red color line with the minus sign is the old version. |
Highlight +<body text="blue" bgcolor="green"> | And the green color line with the plus sign is the new version. |
Press down arrow key
|
Press down arrow key to see more.
|
Show the changes of history.html | Also you can see the changes of the file history.html.
|
Highlight the color lines | Here the output is displayed in colors. |
Highlight red and green color lines
|
If we can’t see the lines with colors, type
|
Type git config --global color.ui false and press Enter | If you don't want to see the colors, please use false instead of true in this command. |
Type git diff Highlight the lines | Type git diff and press Enter. Now the output is displayed without colors.
|
Type git diff history.html and press Enter | Next I will show you how to see the changes in a particular file.
|
Type git add history.html mypage.html press Enter | Let us now add our files to the staging area.
|
Type git diff and press Enter | Let’s check the Git diff again by typing git space diff and press Enter. |
This time we don’t get any output because our files have been added to the staging area. | |
Type git diff --staged and press Enter | In such a case, we can type
git space diff space hyphen hyphen staged and press Enter.
|
Type git diff --cached and press Enter | We can also use
to get the same result. |
How can we compare the current state with any previous commit? | |
Type git log --oneline and press Enter | First we will see the Git log by typing
git space log space hyphen hyphen oneline
|
Type git diff hash and press Enter | Now say, I want to compare my current state with the Initial commit.
|
Show the difference | Here we can see the difference. |
In this manner, we can compare our current state with any previous commit in our repository. | |
In this way, using git diff command we can see all the changes in the modified files.
| |
Let us freeze our work at this point. | |
Type git commit -m “Added colors” and press Enter | To commit, type
git space commit space hyphen m space within double quotes “Added colors” and press Enter.
|
Next, let us learn how to see the difference between two commits. | |
Type git log --oneline and press Enter | Let’s check the Git log by typing
git space log space hyphen hyphen oneline
|
Type git diff hash hash and press Enter | Type git space diff space.
|
Show the difference | The difference between the two given commits can now be seen.
|
Next, we will compare the last revision with the second last revision. | |
Type git diff HEAD HEAD~ and press Enter | Type git space diff space HEAD space HEAD tilde and press Enter. |
Highlight Added colors
|
HEAD indicates the last revision which has the commit message “Added colors”.
|
Slide 5:
|
The latest revision is always HEAD.
The latest minus 1 revision is always HEAD tilde.
Latest minus 2 is HEAD tilde 2, Latest minus 3 is HEAD tilde 3 and so on.
|
Switch back to the terminal | Switch back to the terminal.
|
Type git show and press Enter | Type git space show and press Enter. |
Highlight commit details | This command will show the details of latest commit in the repository.
|
This feature is helpful when we work collaboratively. | |
Type git log --oneline and press Enter | Now, let’s see the Git log by typing
git space log space hyphen hyphen oneline
|
Type git show hash and press Enter
|
To see the details of the Initial commit,
type git space show space.
|
Here you can see the details of the Initial commit. | |
In this manner, we can see the details of any commit of our repository.
| |
Next let us learn how to see the entire history of a file. | |
Type git blame mypage.html and press Enter | To see the entire history of mypage.html,
type git space blame space mypage.html
|
Show the history | Here we can see the entire history of the file mypage.html
i.e. from creation point upto current stage. |
Likewise, you can see the full details of any file in your repository.
| |
Lastly, we will see how to get help from Git. | |
Slide 6:
|
The syntax to get help, is as follows
git <verb> hyphen hyphen help OR man git <verb>
|
Switch back to the terminal
Type git help show and press Enter |
Let me demonstrate this.
git space help space show
|
Here we can see the manual of show command.
| |
With this, we come to the end of this tutorial. | |
Slide 7:
|
Let us summarize.
|
Slide 8:
|
As an assignment
Explore the following commands
|
Slide 9:
Acknowledgement
|
The video at the following link summarises the Spoken Tutorial project.
|
Slide 10:
Acknowledgement |
The Spoken Tutorial Project Team conducts workshops and gives certificates to those who pass online tests.
|
Slide 11:
Acknowledgement |
Spoken Tutorial Project is funded by NMEICT, MHRD, Government of India.
|
This is Priya from IIT Bombay. Thanks for joining. |