git branch -a View local and remote branchesgit branch View all local branchesgit branch -r View all remote branchesgit branch -vv Show local branches associated with remote repositoriesgit checkout -b <branch-name> <existing-branch-name> Create a new branch and switch to the new branchgit checkout <commit-id> -b <new-branch-name> Create a new branch from an existing commit and switch to the new branchgit branch [-f] <branch-name> Create a new branch, but don’t switchgit branch [branch-name] [commit-id] Create a new branch that points to the specified commitgit branch <branch-name> <tag-name> Create a new branch based on the taggit branch <-m|-M> <old-branch-name> <new-branch-name> Rename the branch
#Will not overwrite the same named branch
git branch -m old-branch-name new-branch-name
#Forced rename, will overwrite the same branch
git branch -M old-branch-name new-branch-name
git branch <-d|-D> <branch-name> Delete the local branch
#Branch will fail to delete if it is not merged
git branch -d branch-name
#Branch will also delete successfully if it is not merged
git branch -D branch-name
git branch <-d|-D> -r <branch-name> Delete the remote branchgit checkout <branch-name> switch branches
# Switch to the previous branch
git checkout -
git branch -d -r branch-name
#Don't forget to commit the changes to the remote repository
git push origin :branch-name
git push origin --delete branch-name
git checkout -b test
git push -u origin test
...
#Don't forget to commit your changes to the remote repository
git push