git branch

Git Branching

« PreviousIndex

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:

  1. Select the Branch which you consider as Parent branch(say ‘master’ in this case). Click on + sign in front of Branch drop down.
  2. Select Source Branch
  3. Provide the suitable name of the Local branch. say: feature1
  4. 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:

  1. Select feature1 branch
  2. Stage
  3. Provide Commit description
  4. Commit
  5. Select master branch
  6. Click Rebase
  7. 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:

  1. Select Push
  2. Remote Branch
  3. Select master(in this case)
  4. 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:

  1. Login to GitHub
  2. Goto repository
  3. Click Branch drop down
  4. 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):

  1. 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.
  2. Select Branch to reset from Branch drop down
  3. Click Reset
  4. A pop-up comes. Select the Branch which should be used as a reference for Reset operation
  5. 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!

« PreviousIndex

 

eclipse setting

Eclipse ADT Preferences

cloud vs on prem

HANA On-Premise and Cloud Compared

Leave a Reply

Your email address will not be published. Required fields are marked *