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
 
posted @ 2020-07-26 18:25  Z鸿天  阅读(102)  评论(0编辑  收藏  举报