Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1704209
  • 博文数量: 143
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1462
  • 用 户 组: 普通用户
  • 注册时间: 2016-08-23 11:14
文章分类

全部博文(143)

文章存档

2022年(3)

2021年(13)

2020年(21)

2019年(8)

2018年(28)

2017年(7)

2016年(63)

我的朋友

分类: 敏捷开发

2021-03-07 19:48:36

git fetch origin master //从远程库origin的master分支下载代码到本地, 且更新本地所关联的远程库分支的commit id(.git\refs\remotes\origin\master), 并不会自动合并或修改当前工作. 远程仓库名origin, 并不是指远程仓库, 而是指远程仓库在本地的一个指针(这个指针时会过期的).
git merge origin/master //把远程库origin的master分支合并到当前分支
git pull //= git fetch + git merge
git pull --rebase //= git fetch + git rebase
git rebase //将当前分支重新设置基线

get merge 和 git rebase 区别
1. 相比rebase, merge会产生一个新节点, 而rebase会将两个分支融合成一个线性提交, 不会产生新的节点.
2. 当rebase遇到冲突时, 解决冲突后, git add, git rebase --continue完成了rebase.
  而当merge遇到冲突时, 当前merge就不能再继续进行下去了.
   “Automatic merge failed; fix conflicts and then commit the result.”
   ① 解决冲突.
   ② 一一尝试用以下方式继续:
     git commit --amend //fatal: You are in the middle of a merge -- cannot amend , 未达到我们想要的结果。
    
     git commit //弹出一个新commit, 且显示冲突文件的提交. 未能merge到我们已有commit中, 未达到我们想要的结果。
    
     git merge --continue //弹出一个新commit, 且显示冲突文件的提交. 未能merge到我们已有commit中, 未达到我们想要的结果。
     then git commit //新的commit
    
     git reset --hard last_cherry-pick_commit 或 git reset --merge last_cherry-pick_commit //???如果是本地有冲突而不是cherry-pick有冲突???
     git rebase //因为此次merge出错前已经git fetch过了,这里没必要再做一次,所以直接git rebase就可重新解决冲突
     git rebase --continue完成了rebase

所以,如果正在修改代码时,不能用git pull,要用git pull --rebase,这样做后每次commit里的Change-Id就会用最新的,不会是以前得节点。但时,如果这样做错了用了git pull,用git log就可以查看。然后,用git reset b1dcec2f663e7c017bef03eb329de0e92ca12dd7把代码回到以前得节点。
阅读(2210) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~