git 切换远程地址分支 推送到指定地址分支 版本回退

图片

切换远程地址


1、切换远程仓库地址:


方式一:修改远程仓库地址

【git remote set-url origin URL】 更换远程仓库地址,URL为新地址。

git remote set-url https://gitee.com/xxss/omj_gateway.git

方式二:先删除远程仓库地址,然后再添加

【git remote rm origin】 删除现有远程仓库
【git remote add origin url】添加新远程仓库

git remote rm origin https://github.com/****/omj_gateway.git
git remote add origin  https://gitee.com/xxss/omj_gateway.gi

2、【git remote -v 】查看远程仓库的地址

omj_gateway https://github.com/****/omj_gateway.git (fetch)
omj_gateway https://github.com/xxs/omj_gateway.git (push)
origin https://gitee.com/xxss/omj_gateway.git (fetch)
origin https://gitee.com/xxs/omj_gateway.git (push)

推送到指定地址分支



1、查看本地址和远程版本


git branch -a

  debug
* develop
  main
  remotes/omj_gateway/develop
  remotes/omj_gateway/main
  remotes/origin/HEAD -> origin/main
  remotes/origin/develop
  remotes/origin/main

remotes代表远程分支

2、推送到远程分支

git push <远程主机名> <本地分支名>:<远程分支名>
例:

git push  omj_gateway develop:develop --force

git 版本回退



查看历史版本

1、查看历史版本 详细提交历史 (q退出

git log

q退出

2、 最近提交版本简要

git reflog



回退本地版本

1、回退到上一个版本

git reset --hard  HEAD^


2、回退某个版本

git reset --hard 530ae79


远程服务器回退版本

1、先回退本地git版本
2、查看git分支

git branch -v -a

3、推送到远程git

git push origin HEAD --force

谢谢阅读!请大家帮忙点赞、转发、在看,为小编加鸡腿,请点亮关注,关注我不迷路,更多软硬件开发知识推送给您。

往期精彩

【经验】 cp -rf 命令中参数 -f 失效 ( 依旧要手动确认 )解决愿意付出

【openwrt】MT7628/7688 openwrt下启用串口2 UART2入坑指南

「Shell脚本」Shell脚本程序开发——变量(二)

智能离线语音识别全屋智能语音控制方案

介绍一款高性比的Zigbee无线模块

推荐一款vsCode 可能智能生成代码 代码补全 代码解释 代码纠错 AI插件 iFlyCode

「Shell」Linux shell 脚本编程——认识Shell(一)

【Linux应用开发】fork()函数详解

【openwrt应用开发】openwrt交叉编译自己的应用程序入门--开发类似minicom串口终端

【IC推荐】锦锐单片机CA51F152S4A/B PWM+ADC+触控型8051MCU

openwrt怎么升级固件?使用命令sysupgrade实现openwrt升级固件

最近更新

  1. TCP协议是安全的吗?

    2023-12-18 19:30:03       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-18 19:30:03       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-18 19:30:03       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-18 19:30:03       20 阅读

热门阅读

  1. QT最大线程并发

    2023-12-18 19:30:03       36 阅读
  2. NFTScan 获得比特丛林 (BitJungle) 公司战略投资

    2023-12-18 19:30:03       37 阅读
  3. torch中 squeeze 和 unsqueeze 的不同用法

    2023-12-18 19:30:03       35 阅读
  4. RHEL8中ansible的使用

    2023-12-18 19:30:03       43 阅读
  5. android 的ClassLoader加载dex

    2023-12-18 19:30:03       31 阅读
  6. 飞天使-docker知识点12-docker-compose

    2023-12-18 19:30:03       39 阅读
  7. 15.VLAN

    15.VLAN

    2023-12-18 19:30:03      37 阅读
  8. 第26节: Vue3 绑定到对象

    2023-12-18 19:30:03       41 阅读
  9. 迷茫吗?看看这里

    2023-12-18 19:30:03       36 阅读
  10. JIRA 重置管理员密码

    2023-12-18 19:30:03       39 阅读
  11. 设置Jira启动参数和选项

    2023-12-18 19:30:03       51 阅读
  12. FFmpeg零基础学习(四)——CPU视频解码 重新编码

    2023-12-18 19:30:03       39 阅读