Branching

  1. Branch

git branch

The git branch command allows you to create, list, rename and delete branches.

  • Create Branch

git branch branchName
Ex: git branch Demo
  • List Branch

git branch or git branch --list
  • Delete Branch

git branch -d branchName
Ex: git branch -d Demo
  • Rename Branch

git branch -m branchName
Ex: git branch -m Demo1
  • Delete Remote Branch

git push origin --delete branchName 
Ex: git push origin --delete Demo
  1. Checkout

git checkout

You can switch between two branches with the git checkout command.

git checkout branch Name
Ex: git checkout Demo
  • Create and switch Branch

git checkout -b  branchName
Ex: git checkout -b Demo
  • Discord changes

git checkout --test.txt
  1. Merge

You can merge two branches with the help of git merge command.

git merge
Ex: git merge branch Name
  • Merge into other branch

git merge source branch  target branch
Ex: git merge Demo1 Demo
  1. Cherry-pick

Cherry-picking in Git stands for applying some commit from one branch into another branch.

git cherry-pick commit-ID
Ex: git cherry-pick 1dsfe345
  1. Rebase

Rebasing is a process to re apply commits on top of another base commit.

git rebase
Ex: git rebase Demo
  • Continue to apply changes

git rebase --continue
  • Skip changes and apply

git rebase --skip
  1. Stash

Switch branches without committing the current branch.

git stash
  • Save Stash

git stash save “Msg”
  • List Stash

git  stash list
  • Apply Stash

git stash apply stash ID
Ex: git stash apply 1dsfe345
  • Show Changes

git stash show or git stash show -p

Last updated