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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章