Home Git Branches Cheetsheet
Post
Cancel

Git Branches Cheetsheet

Git Branches Cheatsheet

Terms

  • Head Branch - The currently active or checked out branch is head branch
  • Local Branch - Branches only used locally in system
  • Remote Branch - Branches on web like github or gitlab

Commands

CommandAction
git statusCheck current branch name
  
git branchGet all local branch
git branch -rGet all remote branch
git branch -aGet all local and remote branch
git branch -vGet all branches with hash and commit names
  
git branch Create New Branch
git branch Create branch till perticular commit
  
git checkout Change Branch
git switchOnly Switch/Change branch
  
git branch -m Change current branch name
git branch -m Change perticuar branch name
  
git push origin –deletedelete current / old branch
git push -u origin push new local branch with corrent name
  
git push -u origin Upload local branch
  
git checkout –track origin/track remote branch and local branch will be created with same name
git branch –track origin/track remote branch with local branch
  
git pullpull new changes
git pushpush changes to remote
git branch -vgit branches details
  
git branch -d delete local branch
git push origin –delete delete remote branch
  
git switch mainswitch branch to main
git merge merge current branch with other-branch
  
git switch mainswitch branch to main
git rebase merge current branch with other without showing merge commit in log
  
git log ..compare branch change
  
This post is licensed under CC BY 4.0 by the author.