Git provides a concept called branch. The default branch is called main branch. The main branch contains usually the code of the current productive running code line.
- serves as an abstraction for the staging and commit process.
- works with an independent working directory and staging area.
- is a reference to a commit.
GIT Usage
- git branch List all branches in the repository.
- git branch <branch name> Create a new branch.
- git branch –d <branch name> Delete a branch.
Different Branch Types
Different branch types are used to represent different development activities as indicated by the example branches in this image:
git Checkout
git checkout allows switching between different branches. The following are examples of usage:
- git checkout <yourbranch> Switch to a branch.
- git checkout –b <yourbranch> Create and checkout a new branch.
- git checkout –b <newbranch> <existingbranch> Create and checkout a branch from an existing branch.
git Merge
git merge <yourbranch>Merge a branch into the current branch.