Git

Branching and Merging

Basic commands

List all branches

git branch

Create a new branch

git branch <branch_name>

Switch to a specific branch

git checkout <branch_name>

Merge a branch into the current branch

git merge <branch_name>

Delete a specific branch

git branch -d <branch_name>

List all remote branches

git branch -r

Advanced Commands

List branches with additional information

git branch -vv

Create a new branch based on a remote branch

git checkout -b <branch_name> <remote_name>/<remote_branch>

Cancel merge in case of conflicts

git merge --abort

Rebase the current branch onto another branch

git rebase <branch_name>

Cancel an ongoing rebase operation

git rebase --abort

Interactive rebase for edit, squash, re-order or drop commits

git rebase -i

Rebase commits in the current branch onto a remote branch interactively

git rebase -i <remote_name>/<remote_branch>

On this page