分支管理
创建分支
- 进入仓库。
- 创建分支。
git branch <branch_name>
- 进入仓库。
- 创建分支并切换到该分支。
git checkout -b <branch_name>
查看分支
git branch
切换分支
git checkout <branch_name>
删除分支
git branch -d <branch_name>
分支回退版本
回退到上一个版本。
git reset HEAD^
回退到上上个版本。
git reset HEAD^^
回退到上上上个版本。
git reset HEAD^^^
- 找到对应版本的版本号。
git log
commit id的前4个数为版本号。如下commit的版本号是71d2。
commit 71d26bed7ce2c7aa2d51fc278353658d6a6ce186
- 使用版本号进行回退。
git reset <ver>
合并分支
将分支b合并到分支a中。
- 切换到分支a。
git checkout <branch_name_a>
- 将分支b合并到分支a中。
git merge <branch_name>