git -远程仓库与本地仓库冲突解决
当远程仓库和本地仓库不一致时,在进行push操作时就会报错,这时候的做法:
1 先把远程的代码拉到本地的一个新的分支上:
git fetch remoteName remoteBranch:newBranch
2 查看新的分支和本地分支的区别(可以查看差别)
git diff newBranch
3 将本地分支和新的分支进行合并
git merge newBranch [--allow-unrelated-histories]
注意:其中--allow-unrelated-histories是可选项,当报错“refusing to merge unrelated histories”时加上该选项就可以进行merge。
在进行pull操作时如果也报这个错误也可以加上这个选项。
4 进行push操作就可以
5 删除这个新的分支
git branch -d newBranch
4 当你git reset完之后后悔了,想要再回到之前的
git reflog
找到你要回到的步骤number
git reset --hard number