git pull提醒文件抵触的解决办法
用另一个库笼罩以后库:
git fetch 近程库地址 近程分支
git reset --hard FETCH_HEAD
和本地另一个分支合并,有抵触时主动抉择:
# 主动抉择另一分支的版本
git merge 另一个分支名 -X theirs
# 主动抉择自已的版本:
git merge 另一个分支名 -X ours
和近程库合并,有抵触时主动抉择:
# 主动抉择近程库的版本
git pull 近程库地址 近程分支 -X theirs
# 主动抉择自已的版本:
git pull 近程库地址 近程分支 -X ours
git pull后,针对某个有抵触和文件,抉择近程库的版本:
git checkout --theirs 文件名
git add 文件名
git commit
git pull后,针对某个有抵触的文件,抉择自已的版本:
git checkout --ours 文件名
git add 文件名
git commit
git pull后,针对某个有抵触的文件,在解决前,先查看:
# 查看独特先人的版本:
git show :1:文件名
# 查看自已的版本:
git show :2:文件名
# 查看近程库的版本:
git show :3:文件名
怎么解决”refuse to merge unrelated histories”:
git pull --allow-unrelated-histories 近程库地址 本地分支
# or
git pull --rebase 近程库地址 本地分支
–allow-unrelated-histories 和 –rebase的区别
如果有两个分支
A:1 -> 2
B:1 -> 3
假如对B执行git pull,如果是–allow-unrelated-historys,
git pull --allow-unrelated-histories A master
提交历史将变为
1 -> 2 -> 3 -> "merge 2 and 3"
如果是–rebase
git pull --rebase A master
提交历史将变为
1 -> 2 -> 3
没有 “merge 2 and 3″。
发表回复