git分支
查看分支指向的对象
-
HEAD 一个指向当前所在的本地分支的指针
# 查看各个分支当前所指向的对象 zhanghongtiandeMacBook-Pro:gitLearning zhanghongtian$ git log --oneline --decorate e1c6c23 (HEAD -> master, tag: v1.1-lw, tag: v1.0) 第五次提交2 fa4a84d delete bec3943 第四次提交 b158fc1 (tag: v1.0-lw, v1.0-lw) 第三次提交 fc6bfce 第二次提交 4845ecc first zhanghongtiandeMacBook-Pro:gitLearning zhanghongtian$ zhanghongtiandeMacBook-Pro:gitLearning zhanghongtian$ git log --oneline e1c6c23 (HEAD -> master, tag: v1.1-lw, tag: v1.0) 第五次提交2 fa4a84d delete bec3943 第四次提交 b158fc1 (tag: v1.0-lw, v1.0-lw) 第三次提交 fc6bfce 第二次提交 4845ecc first zhanghongtiandeMacBook-Pro:gitLearning zhanghongtian$ git branch testing # testing 和 master分支当前指向的是同一个对象,当前的本地分支还是master HEAD指向master分支 zhanghongtiandeMacBook-Pro:gitLearning zhanghongtian$ git log --oneline e1c6c23 (HEAD -> master, tag: v1.1-lw, tag: v1.0, testing) 第五次提交2 fa4a84d delete bec3943 第四次提交 b158fc1 (tag: v1.0-lw, v1.0-lw) 第三次提交 fc6bfce 第二次提交 4845ecc first
分支合并
简单分支合并
-
master并入直接上游,git会直接把分支指针向前移动
-
fast-forward 快进
-
被并入的提交快照和要合并的提交快照的直接祖先不是同一个
-
三方指的是(被并入的提交快照、要合并的提交快照、共同祖先)
合并冲突处理
-
冲突提示
zhanghongtiandeMacBook-Pro:gitLearning zhanghongtian$ git merge merge_error_test_v1.2 Auto-merging README.md CONFLICT (content): Merge conflict in README.md Automatic merge failed; fix conflicts and then commit the result. zhanghongtiandeMacBook-Pro:gitLearning zhanghongtian$
git mergetool
分支管理
git branch
git branch -v
# 查看已合并的分支 git branch --merged # 查看未合并的分支 git branch --no-merged