git clone 别人的项目上传到自己的Gitee或者github仓库

git clone别人的项目
git clone https://github.com/wohuweixiya/yft-design.git

进入该项目内,删除原有的.git信息
rm -r .git

初始化.git
git init

将本地代码添加到仓库
git add .

git commit -m "提交仓库说明"

Github上新建一个和这个clone下来的项目名称一样的仓库名,比如你clone下来的这个项目叫my_project,就在Github上新建名为my_project的仓库

关联上远程仓库
git remote add origin 新建的仓库地址

比如:git remote add origin https://gitee.com/username/uniapp-project.git

将代码上传到Github
git push --set-upstream origin master

如果报以下错误:
error: failed to push some refs to 'https://gitee.com/lifexu/uniapp-project.git' hint: Updates were rejected because the remote contains work that you do not hint: have locally. This is usually caused by another repository pushing to hint: the same ref. If you want to integrate the remote changes, use hint: 'git pull' before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.

表示本地仓库和远程仓库的历史没有共同的祖先,Git 默认不允许合并这样的两个仓库。

要解决这个问题,你可以使用 --allow-unrelated-histories 选项来强制 Git 合并这两个不相关的历史。以下是操作步骤:

使用 --allow-unrelated-histories 选项执行 git pull 命令:
git pull origin master --allow-unrelated-histories

如果有合并冲突,你需要手动解决它们,然后创建一个新的提交。

解决完冲突后,再次尝试推送更改到远程仓库:
git push --set-upstream origin master

相关推荐
月初,6 小时前
Git 常用操作大全(超详细教程)一文教会你完全使用Git
大数据·git·elasticsearch
李少兄7 小时前
Git 忽略文件机制:.gitignore 与 .git/info/exclude
java·git·elasticsearch
github.com/starRTC11 小时前
Claude Code中英文系列教程17:将Claude Code集成在GitLab工作流里面
git·gitlab·github
CCC:CarCrazeCurator13 小时前
git merge与rebase的区别及实操心得体会
git
草莓熊Lotso13 小时前
Qt 控件美化与交互进阶:透明度、光标、字体与 QSS 实战
android·java·开发语言·c++·人工智能·git·qt
小明同学0114 小时前
[C++进阶]深入理解二叉搜索树
开发语言·c++·git·visualstudio
muddjsv14 小时前
Git Amend 完全解析:修改最近提交的正确姿势与避坑指南
git
ssxueyi14 小时前
Git 完整安装与环境配置教程(Windows/macOS/Linux 通用)
windows·git·macos·项目管理·git教程·代码管理
摇滚侠15 小时前
在 IDEA 中,GIT 合并分支时选择远程的 dev 分支和本地的 dev 分支,有区别吗
java·git·intellij-idea
可问春风_ren15 小时前
Git命令大全
前端·javascript·git·后端