|
.
Type git branch
. The current branch is indicated by a asterisk *.
git branch name master
→ create a branch named name from “master”. The master
can also be any {commit ID, branch name, tag name}.
Note: this does not switch you to the newly created branch.
Note: before you switch to a branch, best to commit your changes first.
git checkout branch_name
→ update current dir's files to be the branch named branch_name's code. (technically: updating the index, working tree, and HEAD to reflect the specified branch.)
|
WARNING: you should commit before you merge, because, otherwise, when merge has conflicts it's hard to revert to your uncommited pre-merge state.
First, switch to the branch you wan to merge to. For example, git checkout branch_name
.
git merge name
→ merge a branch named name into the current branch (typically the “master”).
Note: merge won't remove a branch. After you merge, you can remove a branch by git branch -d branch_name
|