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

相关推荐
维基框架11 小时前
OpenAI在给Git做优化 上游行为要变了
人工智能·git
1名持续学习的码农11 小时前
GPT Plus、GPT Pro用户第一次用Codex,项目权限和Git分支怎么设置?
人工智能·git·gpt·elasticsearch·ai编程·codex
71777713 小时前
国产 DevOps 新路径:解析 Gitee 软件工厂本土化、信创、AI 核心优势
人工智能·gitee·devops
晨曦中的暮雨1 天前
Learn Claude Code:CodeAgent 与后端程序大搭配——定时任务、Git Worktree 和MCP 服务
git·ai·llm·agent
减瓦1 天前
用 Git 为本地文件打造一台时光机
开发语言·git·编辑器
7177771 天前
自主研发基础设施国产化:信创产业全貌与 Gitee 落地应用
大数据·gitee
Huangjin007_1 天前
【Linux 系统篇(十一)】基础开发工具(六) —— 版本控制器 Git
linux·运维·git
影视飓风TIM2 天前
Linux下C语言缓冲区原理 + Git版本控制
linux·c语言·git
tianyuanwo2 天前
当提交标题重复阻塞CI:Git分支修复实战
git·ci/cd·分支基线调整