Git/C2/Merging-and-Deleting-branches/English-timed

From Script | Spoken-Tutorial
Revision as of 16:06, 1 April 2016 by PoojaMoolya (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Time
Narration
00:01 Welcome to the spoken tutorial on Merging and deleting branches.
00:06 In this tutorial, we will learn about Merging'
00:10 Revert merging and Deleting branches
00:14 For this tutorial, I am using Ubuntu Linux 14.04
00:20 Git 2.3.2 and gedit Text Editor
00:26 You can use any editor of your choice.
00:29 To follow this tutorial you must have knowledge of basics of Git commands and branching in Git.
00:37 If not, for relevant Linux tutorials, please visit our website.
00:42 Earlier in the series, we learnt to create branches.
00:47 Now, we will learn how to merge two branches.
00:51 This diagram illustrates how the new-module branch is merged with the master branch.
00:58 This is done in the C9 commit.
01:01 After merging, the commits of new-module are added to master branch.
01:06 Let me explain how it works.
01:09 First, we will open our Git repository mywebpage which we created earlier.
01:16 Press Ctrl+Alt+T to open the terminal.
01:20 To go into our Git repository, type cd space mywebpageand press Enter.
01:29 I will continue to use html files for demonstration.
01:33 You may use any file type of your choice.
01:38 From here onwards, please remember to press the Enter key after typing every command on the terminal.
01:45 Let us check the git branch list by typing git space branch.
01:51 We can see that we have two branches named master and new-chapter.
01:57 The new-chapter branch was created earlier in this series and master is the default branch.
02:05 Currently, we are in the master branch.
02:08 We will check the Git log by typing git space log space hyphen hyphen oneline
02:17 Let’s go to new-chapter branch and check the Git log.
02:21 Type git space checkout space new-chapter
02:27 Type git space log space hyphen hyphen oneline
02:33 Now we will compare the commits of master and new-chapter branches.
02:38 These four commits are common to both the branches.
02:42 "Added story.html in new-chapter branch" is in new-chapter branch.
02:48 And "Added chapter two in history.html" is in master branch.
02:54 After merging, “Added story.html in new-chapter branch” commit will be added in the master branch.
03:02 Let me demonstrate how to merge now.
03:05 Type git space merge space master
03:09 Gedit opens up automatically to receive the commit message.
03:14 Recall that we have configured gedit as the core editor of Git.


03:20 If you had configured another editor, then that one will open up.
03:26 If you are using a Git version that is below 1.9, then the editor may not open.
03:33 So, you may skip the next step.
03:36 I use the default commit message as it is.
03:40 If you want to give any other message related to the merging, then type it here.
03:46 Now save and close the editor.
03:50 We will check the Git log again.
03:54 You can see that the commits of master branch are merged with new-chapter branch.
04:00 You can also see a commit message for the merging.
04:04 Next, we will go to master branch and check the commits.
04:09 Type git space checkout space master
04:14 Let’s check the Git log.
04:17 Here we should have seen master branch commits along with new-chapter commits.
04:22 But the Git log shows master branch commits only.
04:27 Ideally, we should have merged the new-chapter branch to the master branch.
04:32 But we have merged it the other way around.
04:36 That’s why we can't see the merging commit in the master branch.
04:41 So, how can we revert this merging?
04:45 For this, we will have to go back to the new-chapter branch.
04:50 Type git space checkout space new-chapter
04:54 To revert the merge, type git space reset space hyphen hyphen hard space HEAD tilde
05:04 Recall that latest revision is always HEAD and latest minus 1 revision is always HEAD tilde.
05:12 So we have used HEAD tilde to get the previous revision of merging.
05:18 Let’s check the Git log once again.
05:22 We can see that the merging is discarded now.
05:26 We will now merge the new-chapter branch to the master branch.
05:31 We will go to master branch first by typing git space checkout space master
05:38 Let’s check the Git log again.
05:42 To merge, we will type git space merge space new-chapter
05:48 Give your merging commit message in the gedit.
05:52 Then save and close the editor.
05:55 Again check the Git log.
05:58 We can see that our new-chapter branch has been successfully merged to the master branch.
06:05 Let’s try to merge it again.
06:08 Type git space merge space new-chapter
06:13 Now we see a message that says “Already up-to-date”.
06:17 This is a good way to verify whether we merged or not.
06:22 After merging, the new-chapter branch can be deleted from the Git repository.
06:28 To delete the branch, type git space branch space hyphen d space new-chapter
06:36 Let’s check the branch list once again by typing git space branch
06:43 We can't see new-chapter branch anymore as it has been deleted.
06:48 To delete a branch without merging use hyphen D in uppercase instead of hyphen d in lowercase.
06:56 With this, we come to the end of this tutorial.
07:00 Let us summarize.
07:02 In this tutorial, we have learnt about MergingRevert merging and Deleting branches
07:09 As an assignment check the commits of the branch chapter-two which we created in the previous assignment
07:16 Merge it with the master branch and delete the chapter-two branch
07:22 The video at the following link summarises the Spoken Tutorial project.
07:27 Please download and watch it.
07:30 The Spoken Tutorial Project Team conducts workshops and gives certificates to those who pass online tests.
07:38 For more details, please write to us.
07:41 Spoken Tutorial Project is funded by NMEICT, MHRD, Government of India.
07:48 More information on this Mission is available at the following link.
07:53 This is Priya from IIT Bombay. Thanks for joining.

Contributors and Content Editors

PoojaMoolya, Sandhya.np14