Branching and working - Anjum219/Git-basics GitHub Wiki

git branch is a very useful way when we work with collaboration. We keep a remote repository. We fork and clone the repository. We already have a branch named master. We should create separate branch to work on a separate feature and then finally integrate the branch with the master branch.

To create a branch and checkout to it-

git checkout -b <branch_name>

To checkout (switch) to any branch-

git checkout <branch_name>

To see all the branches-

git branch

To delete a branch locally which is merged with the remote branch

git branch -d <branch_name>

If the branch is not merged yet,

git branch -D <branch_name>

To rename a local branch in git-

git branch -m <old_name> <new_name>
⚠️ **GitHub.com Fallback** ⚠️