Branch
List and Checkout
List:
git branch -a
To checkout a remote branch e.g:
git branch -a
* master
remotes/origin/747-board
To checkout 747-board
:
git checkout -b 747-board origin/747-board
Cherry Pick
How to merge a specific commit in git:
git cherry-pick aeca961
Warning
Checkout the consequence of cherry-picking
Create
git checkout -b ticket-0488
This is shorthand for:
git branch ticket-0488
git checkout ticket-0488
Merge
git checkout master
git merge ticket-0488
Switch
git checkout master
git checkout ticket-0488
A more advanced version (which I don’t understand):
git checkout remotes/origin/0.7.X
Delete
To delete the hotfix
branch:
git branch -d hotfix
Log
To see the branch on the log:
git log --decorate
Remote
From How to check out a remote Git branch?:
git fetch origin
git branch -v -a
git checkout -b test origin/test
With Git versions ≥ 1.6.6, you can just do (doesn’t work for me)!:
git fetch
git checkout test
Rename
From How do I rename a local Git branch?:
git branch -m <oldname> <newname>
If you want to rename the current branch, you can simply do:
git branch -m <newname>
You can use this command to rename master
e.g:
git branch -m master 1010-angular
git checkout live-site
git branch -m live-site master