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

git操作

首先需要有gitbash
在gitbash中,cd想要上传的文件目录,需要用\

cd E:\\bupt\\20250630aic\\code
git init
git add DataGenerate/ (文件夹名)
git commit -m 'version 1' (注释)
git remote add origin  https://github.com/sylviiiiiia/line_chart_generation.git (add一个叫origin的远程)
git pull --rebase origin main (远程仓库里main的分支)
git push origin main(首次推送并建立跟踪关系)

如果最后报错

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.

是因为远程仓库已经存在内容(比如 README、LICENSE 或 .gitignore),而本地没有这些提交,所以 Git 拒绝直接覆盖。
强制覆盖:

git push -f origin main

或者先把远程的改动拉下来合并,再推送

# 拉取远程 main 并自动与本地的 main 做合并
git pull origin main --rebase# 如果没有冲突,直接推送
git push -u origin main

在这里插入图片描述
成功后确认

git log --oneline -5
http://www.xdnf.cn/news/15868.html

相关文章:

  • Node.js:常用工具、GET/POST请求的写法、工具模块
  • ByteBuf 体系的设计与实现
  • `tidyverse` 长表、宽表的处理
  • 【HarmonyOS】ArkUI - 自定义组件和结构重用
  • 处理Electron Builder 创建新进程错误 spawn ENOMEM
  • Spring AI 聊天记忆
  • 28.【.NET8 实战--孢子记账--从单体到微服务--转向微服务】--单体转微服务--币种服务(二)
  • Spring Boot 配置文件解析
  • SpringBoot集成MyBatis的SQL拦截器实战
  • Java学习第六十部分——JVM
  • [硬件电路-52]:什么是模拟电路与数字电路;它们的共同点、核心差异点(原理、目标、关注点等)以及它们如何相互转化
  • LeetCode 852:山脉数组的峰顶索引解析与实现
  • STM32CubeMX的一些操作步骤的作用
  • 7-20 关于mysql
  • 网络安全隔离技术解析:从网闸到光闸的进化之路
  • 【硬件】GalaxyTabPro10.1(SM-T520)刷机/TWRP/LineageOS14/安卓7升级小白向保姆教程
  • RxSwift-事件属性
  • JVM-Java
  • LINUX(三)文件I/O、对文件打开、读、写、偏移量
  • 股票及金融笔记
  • 使用Qt6 QML/C++ 和CMake构建海康威视摄像头应用(代码开源)
  • 双8无碳小车“cad【17张】三维图+设计说名书
  • 【橘子分布式】gRPC(编程篇-下)
  • 嵌入式硬件篇---机械臂运动学解算(3自由度)
  • 机器学习-数据预处理
  • 【机器学习【9】】评估算法:数据集划分与算法泛化能力评估
  • 物联网安装调试-继电器
  • Java设计模式之行为型模式(备忘录模式)实现方式与测试用例
  • 【Unity3D实例-功能-移动】角色移动-通过WSAD(CharacterController方式)
  • 第四次作业