Git Branch¶
check branch¶
use git branch to see current branch
add branch¶
add a branch name after git branch
$ git branch sidebranch
$ git branch
sidebranch
* master
# add branch with commit hash
$ git branch new_branch b174a5a
branch rename¶
delete branch¶
switch branch¶
use -b option when the branch is not exist, it will auto create one new branch
merge branch¶
notice: delete a branch will not remove commit history, we can still got to the target commit
git reflogwill contain 30 days commit history…
rebase¶
rebase will redirect base of current commit to target
$ git rebase dog
First, rewinding head to replay your work on top of it...
Applying: add cat 1
Applying: add cat 2
- cancel rebase
- use
reflogto reset back - use
ORIG_HEAD
- use