How to create new Branches?

Submitted by Rajasekhar on Sat, 11/10/2018 - 13:24
  1. Branches can and should be used often to enable parallel workflows and allow developers to work independently in the same repo. The Git branch command can be used to create new branches.
    • Check out the branch you want to branch from
    • Use Git branch command to create a new branch
    • Check out the new branch and begin working
  2. Git log

  1. Git branch newbranch  → git log


  1. Git checkout newbranch (this moves a head pointer to the new branch) → Git log

  1. Summary: git branch <branch name> to create a new branch pointing to the current commit. Git uses the HEAD pointer to keep track of the current branch. To see where branch pointers are pointing, you can use git log. Use git checkout <branch name> to switch to a different branch. Branches are very fast to create, move and delete. They are just commit hashes written to a file. So lightweight that they can be used often and easily. Can be used to develop features and merged into the master branch later.