git 分支的基本操作

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
posted @ 2015-03-07 21:20  ychongjie  阅读(234)  评论(0编辑  收藏  举报