Branching is the creation of the replica of a particular branch so that parent branch remains unaffected. New branch can have new features and can be used later to merge with parent branch.
Create a new Local branch:
- Select the Branch which you consider as Parent branch(say ‘master’ in this case). Click on + sign in front of Branch drop down.
- Select Source Branch
- Provide the suitable name of the Local branch. say: feature1
- Click OK
Now, Local branch ‘feature1’ contains all the files and folders available in ‘master’. Any change performed in any file/folder of feature1 doesn’t impact master branch. This means, we have now multiple versions of the same project and it is just a matter of Branch drop-down selection and we can work on any version(branch) of the project.
Merge changes(feature1) with Parent branch(master):
Changes in feature1 can be easily merged with Parent branch(master in this case). Follow steps to port changes to master:
- Select feature1 branch
- Provide Commit description
- Select master branch
- Click Rebase
- Select local branch(feature1 in this case) and click OK
Commit on branch feature1 is a prerequisite before it can be merged with master. Merge feature1 changes with GitHub(origin/master) directly: Changes in feature1 can be ‘pushed’ to remote branch directly with following steps:
- Select Push
- Remote Branch
- Select master(in this case)
- Click OK
Note: Later in WebIDE, master branch can do a Fetch followed by Rebase with “Remote origin/master” to get the change of feature1
New remote Branch:
- Login to GitHub
- Goto repository
- Click Branch drop down
- Enter a new Branch name(say ‘GitFeature1’) and Enter(This creates a new remote Feature branch with name ‘GitFeature1’)
Now in WebIDE, we should have two remote branches available for Rebase operation. If feature1 branch was created for Proof of concept or Testing, it is a good idea to sync ‘feature1’ local branch with ‘GitFeature1’ remote branch. In this way, This new branch can be used by any other developer also without impacting master branch.
Note: WebIDE doesn’t have the capability(until the time this blog was written) to create a remote branch!
Reset a Branch(Steps):
- Resetting a branch causes loss of code/information as gone information can’t be retrieved back if Hard reset is selected. Mixed reset keeps committed changes.
- Select Branch to reset from Branch drop down
- Click Reset
- A pop-up comes. Select the Branch which should be used as a reference for Reset operation
- Click OK
Removing a Branch:
A Branch can be simply removed by pressing minus sign in front of Branch drop down. Just select the branch to be removed and click ‘-‘ sign!
6 thoughts on “Git Branching”
You actually make it seem really easy together with your presentation but I in finding this topic to be actually one thing which I think I would never understand. It kind of feels too complex and very large for me. I’m having a look forward in your next submit, I’ll try to get the hold of it!
You actually make it seem really easy along with your presentation however I in finding this topic to be actually one thing which I believe I might never understand. It sort of feels too complex and very broad for me. I’m looking ahead for your subsequent put up, I’ll attempt to get the grasp of it!
Wow, awesome weblog format! How long have you been blogging for? you make blogging look easy. The entire look of your web site is fantastic, as neatly as the content material!
It’s actually a cool and useful piece of information. I’m happy that you shared this useful information with us. Please stay us informed like this. Thanks for sharing.
Helpful info. Fortunate me I found your website unintentionally, and I am stunned why this coincidence did not happened earlier! I bookmarked it.