git branch my-branch
git checkout my-branch
git checkout -b my-branch
if you want to create a branch and reset it if there is an existing one with the same name use -B
option, like this
git checkout -B my-branch
Or if we want to create a new branch and use a different branch as base one write the remote name plus the name of the branch like this
git checkout -b my-branch origin/branch-name
git checkout -b my-branch
if you want to create a branch and reset it if there is an existing one with the same name use -B
option, like this
git checkout -b my-branch origin/other-branch
git branch
or
git branch --list
Note: the current branch will be highlighted in green and marked with an asterisk.
git push -u origin my-branch
git branch -r
or if you want to show both local and remote branches, use instead:
git branch -a
git branch --merged
git branch -a --merged
We need to follow the next steps:
git checkout master
git pull origin master
git branch --merged
git merge my-branch
git push origin master
The first command will delete my-branch
branch locally and the next one remotely and prune it from the list
git branch -d my-branch
git branch -d -r origin/my-branch
git remote prune origin
If we want to see which branches will be prune without actually prune them run this instead
git remote prune origin --dry-run
git remote -v
If we want to remove one of them
git remote rm origin
Above we are deleting the origin
URL from the remote list
This adds another remote to an existing repo