如何查找本地 GIT 存储库的 url

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16452415/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 16:07:15  来源:igfitidea点击:

How to find a url for a local GIT repo

git

提问by Kye

In our Development environment, I can see that the GIT repository was cloned from TEST,

在我们的开发环境中,我可以看到 GIT 存储库是从 TEST 克隆的,

In the config file,

在配置文件中,

[remote "origin"]
   url = //foo/test-foo-project
   fetch = +refs/heads/master:refs/remotes/origin/master

I now want to pull the repository in Development, to my local instance. I know //foo/test-foo-project isn't a real path.. But I can determine which URL to use?

我现在想将 Development 中的存储库拉到我的本地实例。我知道 //foo/test-foo-project 不是真正的路径..但​​我可以确定使用哪个 URL?

采纳答案by jacob aloysious

Git command that could get you the urlfrom origin

可以让你url从的Git 命令origin

$git config --get remote.origin.url

$git config --get remote.origin.url

But you would not be able to set a new path

但是您将无法设置新路径

$git config remote.origin.url "newPath"

$git config remote.origin.url "newPath"

This would fail with the message error: could not lock config file ./config: File exists

这将失败并显示消息错误: could not lock config file ./config: File exists

回答by Wojciech Bednarski

In your home directory do less .shh/configthen you can see the URL for foo.

在您的主目录中 doless .shh/config然后您可以看到foo.

If it is not there you can try git remote showand then probably git remote show origin.

如果它不存在,您可以尝试git remote show,然后可能git remote show origin

Do you remember how you cloned this repo, can you past the command here?

你还记得你是如何克隆这个 repo 的吗,你能在这里通过命令吗?

回答by Shinya Ohtani

Simply you can find a url for a local GIT repo by giturlcommand.

只需通过giturl命令找到本地 GIT 存储库的 url 。

$ gem install giturl
$ giturl .
https://*****/