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!