git switch branch to master code example

Example 1: make a new branch git

git checkout -b branch-name

Example 2: git switch branch

git switch <branch_name>

git checkout <branch_name>

Example 3: git switch branch

git switch branch_name

git checkout branch_name

Example 4: git change master branch

## 1) Rename master branch to oldmaster.
git branch -m master oldmaster
#Now there is no master branch on my local machine.

## 2) Rename my masterTemp branch to master
git branch -m masterTemp master
#The branch which was named masterTemp on my local machine is now master

## 3) Delete the branch from remote
git branch -rD master

## 4) Push the new master branch to remote
git push --force origin master

Example 5: how to switch branches in git

git checkout [branch name]

Example 6: git switch branch

wonder.woman@highfive project %  git checkout branch_name 
#this let you keep edited files
wonder.woman@highfive project %  git switch branch_name

Tags:

Misc Example