Difference between revisions of "Git/C2/Merging-and-Deleting-branches/English"
(Created page with "'''Title of script:''' Merging and deleting branches '''Author:''' Priya K '''Keywords:''' '''Video tutorial, git, branch, merging, deleting, revert merging''' {| style="...") |
Nancyvarkey (Talk | contribs) |
||
Line 27: | Line 27: | ||
* Revert '''merging''' and | * Revert '''merging''' and | ||
* Deleting '''branches''' | * Deleting '''branches''' | ||
− | |||
− | |||
|- | |- | ||
Line 54: | Line 52: | ||
* You must have knowledge of basics of''' Git''' commands and''' branching '''in '''Git'''. | * You must have knowledge of basics of''' Git''' commands and''' branching '''in '''Git'''. | ||
− | * If not, for relevant tutorials, please visit our website. | + | * If not, for relevant '''Linux''' tutorials, please visit our website. |
− | + | ||
− | + | ||
|- | |- | ||
Line 75: | Line 71: | ||
− | This | + | This is done in the''' C9''' commit. |
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
Line 163: | Line 156: | ||
Highlight '''Added chapter two in history.html''' | Highlight '''Added chapter two in history.html''' | ||
− | | style="border:1pt solid #000000;padding:0.097cm;"| ''' | + | | style="border:1pt solid #000000;padding:0.097cm;"| '''"Added story.html in new-chapter branch"''' is in''' new-chapter branch.''' |
− | And''' | + | And''' "Added chapter two in history.html"''' is in''' master branch.''' |
|- | |- | ||
Line 347: | Line 340: | ||
|- | |- | ||
| style="border:1pt solid #000000;padding:0.097cm;"| Type''' git branch''' and press''' Enter''' | | style="border:1pt solid #000000;padding:0.097cm;"| Type''' git branch''' and press''' Enter''' | ||
− | | style="border:1pt solid #000000;padding:0.097cm;"| Let’s check the branch list once again by typing''' git space branch''' | + | | style="border:1pt solid #000000;padding:0.097cm;"| Let’s check the '''branch''' list once again by typing''' git space branch''' |
Line 354: | Line 347: | ||
|- | |- | ||
| style="border:1pt solid #000000;padding:0.097cm;"| Highlight''' -d''' in the deleting command | | style="border:1pt solid #000000;padding:0.097cm;"| Highlight''' -d''' in the deleting command | ||
− | | style="border:1pt solid #000000;padding:0.097cm;"| To delete a '''branch '''without '''merging''', use''' hyphen D''' in uppercase instead of '''hyphen d '''in lowercase. | + | | style="border:1pt solid #000000;padding:0.097cm;"| To delete a '''branch '''without '''merging''', |
+ | *use''' hyphen D''' in uppercase | ||
+ | *instead of '''hyphen d '''in lowercase. | ||
Line 377: | Line 372: | ||
* Revert '''merging '''and | * Revert '''merging '''and | ||
* Deleting '''branches''' | * Deleting '''branches''' | ||
− | |||
− | |||
|- | |- | ||
Line 395: | Line 388: | ||
* Merge it with the''' master branch '''and | * Merge it with the''' master branch '''and | ||
* Delete the''' chapter-two branch''' | * Delete the''' chapter-two branch''' | ||
− | |||
− | |||
|- | |- |
Latest revision as of 19:16, 14 August 2015
Title of script: Merging and deleting branches
Author: Priya K
Keywords: Video tutorial, git, branch, merging, deleting, revert merging
|
|
Slide 1:
Merging and deleting branches |
Welcome to the spoken tutorial on Merging and deleting branches. |
Slide 2:Learning Objectives
|
In this tutorial, we will learn about
|
Slide 3:
System requirement
|
For this tutorial, I am using
You can use any editor of your choice. |
Slide 4:
Pre-requisites
|
To follow this tutorial
|
Earlier in the series, we learnt to create branches.
| |
Slide 5:
Merging diagram
|
This diagram illustrates how the new-module branch is merged with the master branch.
|
Slide 6:
After Merging
|
After merging, the commits of new-module are added to master branch.
|
Press Ctrl+Alt+T to open the terminal | First, we will open our Git repository mywebpage which we created earlier.
|
Type cd mywebpage and press Enter | To go into our Git repository, type cd space mywebpage
|
I will continue to use html files for demonstration.
| |
From here onwards, please remember to press the Enter key after typing every command on the terminal. | |
Type git branch and press Enter
|
Let us check the branch list by typing git space branch.
|
Highlight new-chapter >> Highlight master | The new-chapter branch was created earlier in this series and master is the default branch. |
Highlight * master | Currently, we are in the master branch. |
Type git log --oneline and press Enter | We will check the Git log by typing git space log space hyphen hyphen oneline |
Type git checkout new-chapter and press Enter | Let’s go to new-chapter branch and check the Git log.
|
Type git log --oneline and press Enter | Type git space log space hyphen hyphen oneline |
Now we will compare the commits of master and new-chapter branches. | |
Highlight the first 4 commits of master and new-chapter branch | These four commits are common to both the branches. |
Highlight Added story.html in new-chapter branch
|
"Added story.html in new-chapter branch" is in new-chapter branch.
|
After merging, “Added story.html in new-chapter branch” commit will be added in the master branch.
| |
Type git merge master and press Enter | Let me demonstrate how to merge now.
|
Gedit opens up automatically to receive the commit message.
| |
Highlight the first line of gedit
|
I use the default commit message as it is.
|
Type git log --oneline and press Enter | We will check the Git log again. |
Highlight the commits | You can see that the commits of master branch are merged with new-chapter branch. |
Highlight the merge commit message | You can also see a commit message for the merging. |
Type git checkout master and press Enter | Next, we will go to master branch and check the commits.
|
Type git log --oneline and press Enter | Let’s check the Git log.
|
Highlight the Git log | Ideally, we should have merged the new-chapter branch to the master branch.
|
So, how can we revert this merging? | |
For this, we will have to go back to the new-chapter branch. | |
Type git space checkout space new-chapter | Type git space checkout space new-chapter |
Type git reset --hard HEAD~ and press Enter | To revert the merge, type git space reset space hyphen hyphen hard space HEAD tilde |
Highlight HEAD~ | Recall that latest revision is always HEAD and latest minus 1 revision is always HEAD tilde.
|
Type git log --oneline and press Enter | Let’s check the Git log once again. |
We can see that the merging is discarded now.
| |
We will now merge the new-chapter branch to the master branch. | |
Type git checkout master and press Enter | We will go to master branch first by typing git space checkout space master |
Type git log --oneline and press Enter | Let’s check the Git log again. |
Type git merge new-chapter and press Enter
|
To merge, we will type git space merge space new-chapter
|
Type git log --oneline and press Enter | Again check the Git log. |
We can see that our new-chapter branch has been successfully merged to the master branch. | |
Type git merge new-chapter and press Enter | Let’s try to merge it again.
|
Highlight “Already up-to-date” | Now we see a message that says “Already up-to-date”.
|
After merging, the new-chapter branch can be deleted from the Git repository. | |
Type git branch -d new-chapter and press Enter | To delete the branch, type git space branch space hyphen d space new-chapter |
Type git branch and press Enter | Let’s check the branch list once again by typing git space branch
|
Highlight -d in the deleting command | To delete a branch without merging,
|
With this, we come to the end of this tutorial. | |
Slide 7:
Summary
|
Let us summarize.
|
Slide 8:
Assignment
|
As an assignment
|
Slide 9:
Acknowledgement
|
The video at the following link summarises the Spoken Tutorial project.
|
Slide 10:
Spoken Tutorial Workshops
|
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. |