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
| Command | Action |
|---|---|
| git status | Check current branch name |
| git branch | Get all local branch |
| git branch -r | Get all remote branch |
| git branch -a | Get all local and remote branch |
| git branch -v | Get all branches with hash and commit names |
| git branch | Create New Branch |
| git branch | Create branch till perticular commit |
| git checkout | Change Branch |
| git switch | Only Switch/Change branch |
| git branch -m | Change current branch name |
| git branch -m | Change perticuar branch name |
| git push origin –delete | delete 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 | track remote branch with local branch |
| git pull | pull new changes |
| git push | push changes to remote |
| git branch -v | git branches details |
| git branch -d | delete local branch |
| git push origin –delete | delete remote branch |
| git switch main | switch branch to main |
| git merge | merge current branch with other-branch |
| git switch main | switch branch to main |
| git rebase | merge current branch with other without showing merge commit in log |
| git log | compare branch change |