修改Git远程仓库地址

DevOps GitLab评论2,203字数 1557阅读5分11秒阅读模式

1、使用Git命令修改远程仓库

修改远程仓库

  • 进入本地代码目录
devops@bogon ~ % cd demo
  • 查看远程仓库地址
devops@bogon demo % git remote -v
origin        git@192.168.1.10:devops/demo.git (fetch)
origin        git@192.168.1.10:devops/demo.git (push)
  • 修改远程仓库地址,把192.168.1.10换成192.168.12.10即可,其他保持默认。
devops@bogon demo % git remote set-url origin git@192.168.12.10:devops/demo.git
  • 查看修改后的仓库地址
devops@bogon demo % git remote -v 
origin        git@192.168.12.10:devops/demo.git (fetch)
origin        git@192.168.12.10:devops/demo.git (push)
  • 代码合并,以原分支为主。
devops@bogon demo % git pull --rebase origin master
From 192.168.12.10:devops/demo
 * branch            master     -> FETCH_HEAD
Already up to date.
devops@bogon demo % ls
README.md        mvnw                mvnw.cmd        pom.xml                src

模拟代码变更提交

  • 提交分支,以原分支为主。
devops@bogon demo % vi pom.xml 
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
devops@bogon demo % git add .
devops@bogon demo % git commit -m "update-test"
[master 7e2c67c] update-test
 1 file changed, 1 insertion(+), 1 deletion(-)
devops@bogon demo % git push -u origin master
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 291 bytes | 291.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
To 192.168.12.10:devops/demo.git
   b5f9057..7e2c67c  master -> master
branch 'master' set up to track 'origin/master'.

2、使用Sourcetree修改远程仓库

  • 点开远程仓库
  • 点击设置
  • 点击远程仓库
  • 编辑仓库地址
  • 把192.168.1.10改成192.168.12.10,点击确定。

合并远程分支

  • 拉取
  • 所有的钩都去掉,点击确定。

3、直接删除远程仓库地址,创建远程克隆

  • 删除sourcetree远程仓库
  • 复制新的gitlab仓库地址,创建远程克隆。

继续阅读
DevOps
  • 本文由 发表于 2022年12月28日 20:03:10
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
Gitlab配置HTTPS GitLab

Gitlab配置HTTPS

简述 gitlab最新是开启https会自动配置,但只有三个月有效期,使用自己设的加密证书应设置。 配置 [root@iZ8vb3ycs3gfmlbmyxy6efZ ~]# vim /etc/g...
GitLab 中配置添加 SSH 密钥 GitLab

GitLab 中配置添加 SSH 密钥

1、GitLab配置添加SSH Key 本机已有公钥忽略,不需要生成,直接添加即可。 客户端配置生成SSH密钥对 ssh-keygen -t rsa -C "YOUR EMA...
评论  0  访客  0

发表评论