![git 分支的基本操作 git 分支的基本操作](https://image.shishitao.com:8440/aHR0cHM6Ly9ia3FzaW1nLmlrYWZhbi5jb20vdXBsb2FkL2NoYXRncHQtcy5wbmc%2FIQ%3D%3D.png?!?w=700&webp=1)
git分支的基本操作。
创建私有分支:
$git branch branchName commitID
$git checkout -b branchName commitID
注意:git checkout -b branchName commitID = git branch branchName commitID + git checkout branchName。
合并分支(合并前需要切换到目标分支):
$git merge sourceBranch
$git cherry-pick commitID
查看分支:
$git branch (-a) (-r)
$git branch --merged 查看合并到当前分支的所有分支
$git branch --no-merged 查看还没有合并到当前分支的所有分支
删除私有分支:
$git branch -d/-D branchName
-d:检查是否合并到其它分支/-D: 不检查强制删除
重命名分支:
$git branch -m oldBranch newBranch