git 常用命令|合并远程仓库代码

免密登陆命令

git config --global credential.helper store

删除远程 分支

git push origin --delete master

将暂存区的文件从暂存区撤出

git restore --staged <file>

git 强制覆盖本地分支

当前分支设置为 origin/master 分支

git reset --hard origin/master

将重置后的 master 分支强制推送更新

git push origin master -force

合并远程仓库代码到自己仓库

添加远程仓库链接

git remote add upstream ${url}

将远程所有的分支fetch下来,存在本地

git fetch upstream

开始合并 (指定 master 分支)

git merge upstream/master

git merge 常见问题

拒绝合并无关的历史

git merge ${branch-anme} --allow-unrelated-histories 

合并冲突

错误信息: Automatic merge failed; fix conflicts and then commit the result.

1、可以手动解决
2、被合并分支为主,强制合并代码
git checkout --ours ${codefile}
3、合并分支为主,强制合并代码
git checkout --theirs ${codefile}
4、然后添加冲突文件为已解决并继续
git add ${codefile }
git merge --continue
暂无评论
本文作者:
本文链接: https://www.qinless.com/?p=338
版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 qinless 的博客!
100

发表评论

返回顶部