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

gitlab相关操作

2025.06.11今天我学习了如何在终端使用git相关操作:

一、需要修改新的仓库git地址的时候:

(1)检查当前远程仓库

git remote -v 

输出示例:

 origin https://github.com/old-repo.git (fetch)

 origin https://github.com/old-repo.git (push)

方案一:删除已有的远程仓库并重新添加

如果需要更换远程仓库,首先删除已有的origin,然后重新添加新的远程仓库。

# 删除已有的远程仓库

git remote remove origin

# 重新添加新的远程仓库

git remote add origin https://github.com/new-repo.git

# 验证新的远程仓库

git remote -v

输出示例:

origin https://github.com/new-repo.git (fetch)

origin https://github.com/new-repo.git (push)

方案二:修改已有远程仓库的URL

如果只是想修改远程仓库的URL,可以使用git remote set-url命令。

# 修改远程仓库的URL

git remote set-url origin https://github.com/new-repo.git

# 验证新的远程仓库

git remote -v 

输出示例

origin  https://github.com/new-repo.git (fetch)
origin  https://github.com/new-repo.git (push) 

3. 提交代码

在成功修改或重新添加远程仓库后,可以按照正常的Git提交流程推送代码。

# 切换到main分支
git checkout main

# 拉取最新代码(避免冲突)
git pull origin main --rebase

# 添加修改
git add .

# 提交更改
git commit -m "更新代码"

# 推送到GitHub
git push -u origin main

 

 转载来自:

Git报错fatal: remote origin already exists的远程仓库管理_remote origin already exists.-CSDN博客

、git提交到远程仓库:

1.将本地的Git仓库与远程仓库关联

git remote add origin http://1.1.1.1/dsic/Simulator.git

2.加入暂存区(.是将文件夹内所有修改的文件、文件夹都暂存,也可以手动选择文件进行暂存) 

git add .

git add -f dist 

3.提交说明(-m后面是需要提交的说明) 

git commit -m '提交内容说明' 

4.查看当前分支 

git branch 

5.上传代码到分支 

git push origin master 

转载来自:

本地项目推送到gitlab仓库的保姆级教程_如何将本地项目上传到gitlab-CSDN博客 

相关文章:

  • Redis GEO 底层实现(结合源码分析)
  • Redis的主从复制底层实现
  • 【编译工具】(调试)Chrome DevTools + Postman:调试组合如何让我的开发效率提升400%?
  • Guava常用工具类使用教程
  • 《Redis》持久化
  • Oracle线上故障问题解决
  • SpringMVC异步处理Servlet
  • Flask应用中处理异步事件(后台线程+事件循环)的方法
  • 达梦数据库 单机部署dmhs同步复制(DM8—>DM8)
  • 高频面试之6Hive
  • Redis: List类型
  • Redis免费客户端工具推荐
  • Github月度新锐热门工具 - 202506
  • [HarmonyOSNext鸿蒙开发]11.ArkUI框架:Swiper、Grid布局与代码复用实战指南
  • Spring Boot 集成 Redis 实战教程
  • spring boot源码和lib分开打包
  • AWS CloudFormation实战:构建可复用的ECS服务部署模板
  • AWS TAM行为面试模拟题
  • onnx 模型转 rknn 部署 rk3588 开发板
  • Centos与RockLinux设置静态ip
  • 怎么样做网站管理员/关键词排名怎么做好
  • 网站建设切片效果是什么/seo关键词优化策略
  • 京东商城企业网站建设分析/谷歌浏览器官网下载
  • 成都业务网络推广平台/惠州seo博客
  • 单位建设网站用途/百度关键词优化曝光行者seo
  • 武汉高端网站定制设计/小果seo实战培训课程