Git branching feature is the most notable feature provided by Git for parallel development without impacting other developers. Using git branches, Developers can work on different module parallel with same base code and merge them later into one to build the complete picture.
We will start with the simple branching scenarios, where 2 branch has been initiated with same base code and merge them into one after few modifications.
a. List Git Branch:
==
b. Create Git Branch:
==
By above command, you can create a branch which has the same base code as master and when you list the branch, now you can see 2 names - atul (branch we created) and master (original). Asterisk * sign will tell us which repo is currently active.
c. Switch to Git Branch (checkout branch):
===
d. Let's make some changes in the branch:
To make some changes, what I have done is created a new file name "atul.txt" and committed to this branch named "atul". You can found all the commands as below -
= =
now, we have made the changes, let's check the git log for this branch -
Here we have to understand one important branching concept, as you can see there are 2 branches (master and atul) pointer.
origin/master, master - this pointer will tell this branch "atul" has been branched from "master" from this commit de70bc2450802c80dc5520afa20b53de30488e5a
HEAD -> atul, origin/atul - this pointer will tell you that HEAD is pointing to "atul" branch means you are inside "atul" branch and commit 0ba89ab2d62a74c48951ba20b2c0f369c9a675a3 has been done
Let's quickly move to master branch and check whether these changes are there or not ??
e. Moving back to master:
Moving back process is the same as moving into the branch and check the git log in "master" branch
Here you can see that changes which we have committed inside "atul" branch hasn't been reflected in "master" branch.
This is how Git support Parallel Development with branching where the developer can create their own branch and develop the different features parallel.
f. What's the differences:
We have created 2 branches named: "master" & "atul" and made some additional changes inside "atul" branch and commit to it. We can check the difference between these 2 branches by executing below command :
==
We will discuss about how to interpret this diff report in the next post, till then.....Happy Learning........
Facebook Page Facebook Group Twitter Feed Google+ Feed Telegram Group