【问题标题】:How to know the origin of the remote repository?如何知道远程仓库的来源?
【发布时间】:2015-04-05 17:07:26
【问题描述】:

我正在尝试更新 ssh://xxxxx@idating1-idating1.rhcloud.com/~/git/idating1.git 中的代码,该代码由 openshift 为项目 idating1 提供。但由于某些原因,我的 mac 无法正确设置 rhc。我成功地 git clone 源代码。如何将代码更改推送到 ssh://xxxx@idating1-idating1.rhcloud.com/~/git/idating1.git?我不知道起源的名字是什么。

【问题讨论】:

  • 只要说git remotegit remote -v
  • 您需要提供具体细节。您尝试了什么,会发生什么,您认为应该发生什么,为什么会这样。

标签: git openshift


【解决方案1】:

您需要git remote -v | grep /part/of/the/url 来获取远程上游仓库的名称。 (见git remote

你也可以在git config --local -l看到它

如果你不想做 grep,git config 可以为你做:

git config --get-regexp remote.* b2d

remote.origin.url https://VonC@github.com/VonC/b2d.git
       ^^^^^^
          |
          --- name of the remote, for an url including "b2d"

这将 grep 任何 remote.* 键,任何值包括回购 url 的一部分(这里,在这个例子中只是它的名字)


如果 git remote -v 什么都不返回,那么本地没有设置远程。
添加一个:

cd /path/to/local/repo
git remote add origin /url/to/remote/repo
git push -u origin master

【讨论】:

  • 它不起作用。我使用的系统是 OS X。它什么也不返回。你能告诉我在终端中编写什么代码来获取远程 git 存储库的来源吗?我唯一知道的是存储库的 url。
  • @michaelsgx 如果它什么都不返回,这意味着你没有远程设置:只需设置一个:git remote add origin /url/of/remote/repo
  • @michaelsgx 如果你已经克隆了 repo,git remote -v 不应该为空。
【解决方案2】:

回购没有内在名称——它们甚至没有内在网址。这次只有你如何称呼他们。

您可以使用git ls-remote u://r/l 查看远程存储库对其自己的远程存储的名称,但我很确定没有办法发现它为它们使用的 url。

您为遥控器使用的名称完全是任意的。 origin 只是克隆设置的遥控器的一个方便的常规名称。

你甚至根本不需要名字;对于一次性推送和获取,您可以直接使用 url。

【讨论】:

    猜你喜欢
    • 2014-02-17
    • 2022-07-11
    • 2012-06-26
    • 2018-02-06
    • 2016-11-18
    • 2013-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多