Git 的 SSH URL 什么时候变成不需要 ssh:// 的了?有什么办法批量修改么?

2017-07-28 01:43:40 +08:00
 Sliverburger

可能是火星了,前两天还用的好着呢 最近安装了个 SourceTree,不知道是不是更新了 Git 的版本还是怎么回事

git pull / git push 无法使用了 !!!!

提示:

ssh: Could not resolve hostname github.com:angular: nodename nor servname provided, or not known
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

然后研究了一下,主要是 git 对于远程 URL 配置部分好像是改了,以前是这样:

[remote "origin"]
	url = ssh://git@github.com:angular/angular.git
	fetch = +refs/heads/*:refs/remotes/origin/*
	pushurl = ssh://git@github.com:angular/angular.git

现在是这样:

[remote "origin"]
  url = git@github.com:Yelp/elastalert
  fetch = +refs/heads/*:refs/remotes/origin/*

不确定是不是 pushrul 不需要了,但可以确定的是 ssh:// 这部分不需要了? (谁能解释下这是新版这样的?还是说老版这样的?用 brew 安装的是 2.13.3

那么现在主要问题就来了,有什么办法批量修改这部分的东西么?本地有大约 30 多个 repo 都需要更新

2277 次点击
所在节点    问与答
2 条回复
msg7086
2017-07-28 01:49:18 +08:00
我记得我一直用的是 git@gitlab.com:name/repo 这样的格式啊。

批量修改的话 sublime 不行吗,Find all files 功能。
sed in place 也行。
Sliverburger
2017-07-29 02:05:39 +08:00
@msg7086 好吧谢谢,最后写了个 sed 改好了
我也不知道以前为什么有 ssh:// 可能是 clone 的太早了吧

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/378492

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX