Git Branch-分支
# 基本理解
分支是指向提交对象的指针。 Git 分支默认名是master, 因为 政治正确改成了 main。 每一次提交操作, 都会自动向前移动。 分支的创建删除是一个指针的创建和移动, 所以Git 鼓励开发人员 频繁使用分支
# 基本命令
# Git branch/ git checkout
git branch issue53 ## 创建一个 issue53 的分支
git checkout issue53 ## 切换到 issue53 的分支
## 前面两句等于下面一句
git checkout -b issue53
## 分支切换
git checkout main ## issue53
## 当完成分支合并,可以删除分支
git branch -d issue53
# git merge
git merge issue53
# git rebase
git checkout main
git rebase issue53
# 分支的合并
git checkout-b module
## do something
git commit -am "do something"
## do something
git commit -am "do something"
git checkout -b issue53
## fixing issue53
git commit -am "fixing issue53 now"
## hotfixed
git checkout -b hotfixed
## fix hotfix
git commit -am "hotfixed done"
git checkout main
git merge hotfix
## check branch issue53
git checkout issue53
git commit -am "fixed issue53"
git checkout main
git merge issue53
# git rebase 和 git merge 的不同
git rebase 可以保证提交树的整洁 git merge 可以保证提交历史 由此诞生出两派, 一种认为需要保证提交的历史, 认为提交历史不能被修改。 一种认为提交历史并不重要,重要的是干净的、线性的提交历史,没有不必要的合并提交。