当前位置: 首页 > news >正文

github上传本地项目过程记录

最近有和别人进行unity项目协作的需求,需要把自己的本地代码上传到github已有的一个仓库里。记录一下上传过程,防止后续还需要用。

文章目录

  • 一、把自己的本地代码上传到github已有的一个仓库中
  • 二、常用功能


一、把自己的本地代码上传到github已有的一个仓库中

首先可以借鉴这个博主的做法,生成ssh密钥、添加ssh key到github项目。https://blog.csdn.net/Natsuago/article/details/145646982
这样做的目的是为了安全地验证你的身份,让你可以在不输入用户名和密码的情况下,通过加密通道与 GitHub 仓库进行交互。

然后,按照如下步骤操作:
(1)克隆github项目到本地

git clone git@github.com:用户名/项目名

(2)把本地 Unity 项目的内容复制到这个文件夹里
把已有的 Unity 项目的 Assets/, Packages/, ProjectSettings/ 等拷贝进克隆下来的文件夹中。

(3)进入项目文件夹,并添加变动

cd 项目文件夹名称
git add .
git commit -m "Add local Unity project code"

(4)推送到github

git push origin main  # 如果主分支是 main
# 或者
git push origin master  # 如果主分支是 master

注意备份!这个操作可能会覆盖远程已有的内容。

二、常用功能

1. 更新远程仓库URL(从HTTPS改成SSH)
检查当前远程配置:

git remote -v  # 查看现有远程仓库

若显示 HTTPS 格式(如 https://github.com/…),更新为 SSH:

git remote set-url origin git@github.com:用户名/仓库名称

2.查看当前所在的分支是什么

git branch

3.如何放弃当前.git历史,重新初始化一个干净的git仓库上传

# 1. 先备份当前代码(可选)
cd ..
cp -r Interactive-Physics-Based-Gaussian-Splatting-Real-Time-Visualization-Editing backup_project# 2. 删除 Git 跟踪信息(包括所有历史记录和大文件)
cd Interactive-Physics-Based-Gaussian-Splatting-Real-Time-Visualization-Editing
rm -rf .git# 3. 重新初始化仓库
git init
git remote add origin https://github.com/yourname/yourrepo.git  # ← 换成你的仓库地址
echo "cuda_11.8.0_520.61.05_linux.run" >> .gitignore
git add .
git commit -m "Initial clean commit"
git push -f origin master  # 或 main,看你用哪个分支

如果出现下面这个情况:

(base) 用户名@dbcloud:~/projects/github/Interactive-Physics-Based-Gaussian-Splatting-Real-Time-Visualization-Editing$ git add .
warning: adding embedded git repository: gaussian-splatting/SIBR_viewers
hint: You've added another git repository inside your current repository.
hint: Clones of the outer repository will not contain the contents of
hint: the embedded repository and will not know how to obtain it.
hint: If you meant to add a submodule, use:
hint: 
hint:   git submodule add <url> gaussian-splatting/SIBR_viewers
hint: 
hint: If you added this path by mistake, you can remove it from the
hint: index with:
hint: 
hint:   git rm --cached gaussian-splatting/SIBR_viewers
hint: 
hint: See "git help submodule" for more information.
warning: adding embedded git repository: gaussian-splatting/submodules/diff-gaussian-rasterization
warning: adding embedded git repository: gaussian-splatting/submodules/fused-ssim
warning: adding embedded git repository: gaussian-splatting/submodules/simple-knn

说明你在一个 Git 仓库(我们称为 父仓库)中添加了 其他 Git 仓库(子仓库),Git 把这些子仓库当成是 嵌套仓库 或 子模块,而不是普通目录。

如果你是 有意 把这些作为子模块(submodule),推荐使用:

git submodule add <URL> gaussian-splatting/SIBR_viewers

否则,推荐 不要直接把它们 add 进来,可以用以下命令移除:

git rm --cached gaussian-splatting/SIBR_viewers
git rm --cached gaussian-splatting/submodules/diff-gaussian-rasterization
git rm --cached gaussian-splatting/submodules/fused-ssim
git rm --cached gaussian-splatting/submodules/simple-knn

之后可以在 .gitignore 文件中添加它们:

echo "gaussian-splatting/SIBR_viewers/" >> .gitignore
echo "gaussian-splatting/submodules/" >> .gitignore

如果你忽略这些 warning 把它们提交了,其他人克隆你的仓库时,这些子模块内容不会被包含进来,他们会看到的是一个空目录,除非手动初始化子模块,这会带来很多困扰。

http://www.lryc.cn/news/601183.html

相关文章:

  • 【C语言网络编程基础】DNS 协议与请求详解
  • STM32的蓝牙通讯(HAL库)
  • 飞牛NAS本地化部署n8n打造个人AI工作流中心
  • 用 Flask 打造宠物店线上平台:从 0 到 1 的全栈开发实践
  • idea总结
  • JVM工具
  • 【优选算法】BFS解决FloodFill算法
  • Element表格单元格类名动态设置
  • VILA系列论文解读
  • 基于mnn架构在本地 c++运行llm与mllm模型
  • PostgreSQL AND OR 操作符详解
  • esp32s3创建rust工程 window成功mac
  • 前后端分离:架构模式与实践
  • Qt 分裂布局:QSplitter 使用指南
  • 四、搭建springCloudAlibaba2021.1版本分布式微服务-加入openFeign远程调用和sentinel流量控制
  • UNet 改进(38):融合多尺度输入与可变形卷积、门控特征融合的医学图像Unet分割网络
  • MySQL 事务和锁
  • 02人工智能中优雅草商业实战项目视频字幕翻译以及声音转译之以三方AI模型API制作方式预算-卓伊凡|莉莉
  • 车载诊断架构 ---面向售后的DTC应该怎么样填写?
  • KNN算法实战:手写数字识别详解
  • 前端基础班学习路线
  • Git+宝塔面板部署Hugo博客
  • net8.0一键创建辅助开发的个人小工具
  • 剑指offer第2版:双指针+排序+分治+滑动窗口
  • 零基础学习性能测试第五章:JVM性能分析与调优-GC垃圾分代回收机制与优化
  • 【嵌入式硬件实例】-555定时器调光电路实现
  • 工业控制系统安全之 Modbus 协议中间人攻击(MITM)分析与防范
  • DAY21-二叉树的遍历方式
  • 数据结构 堆(4)---TOP-K问题
  • Canvas实现微信小程序图片裁剪组件全攻略