如何查找或更改 Git 存储库服务器的 url

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5962963/
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-19 05:27:13  来源:igfitidea点击:

How to find out or change url for Git Repository server

gitubuntugitosis

提问by Timus83

I've installed Git and Gitosis on Ubuntu server which has 3 domain names parked. How do I know, which of these domain names are used by Git to construct Git access url, like for example, this: git@xxxxxxxx/repository.git Where can I set up this xxxxxxx value? Thank you in advance, Git looks to be great.

我已经在 Ubuntu 服务器上安装了 Git 和 Gitosis,它有 3 个域名。我怎么知道 Git 使用这些域名中的哪些来构建 Git 访问 url,例如: git@xxxxxxxx/repository.git 我在哪里可以设置这个 xxxxxxx 值?预先感谢您,Git 看起来很棒。

回答by Michael De Silva

(1) As for the domain names - as long as they all resolve to the server IP, it shouldn't matter. Git ultimately connects over SSH, in this case to your gitosis server. If you can connect via SSH to your machine via any of those parked domains, you can use it as your git url.

(1) 至于域名——只要都解析到服务器IP就可以了。Git 最终通过 SSH 连接,在这种情况下连接到您的 gitosis 服务器。如果您可以通过任何这些停放的域通过 SSH 连接到您的机器,则可以将其用作您的 git url。

I don't believe that git allows you to list multiple urls per remote, so if you want to have all three listed (worst case scenario perhaps) just setup three remotes, each with a different domain to your server.

我不相信 git 允许您为每个遥控器列出多个 url,因此如果您想列出所有三个(可能是最坏的情况),只需设置三个遥控器,每个遥控器都有不同的域到您的服务器。

(2) That's really simple. Check out your .git/configfile inside your project directory.

(2) 这真的很简单。检查.git/config您的项目目录中的文件。

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
[remote "origin"]
    url = [email protected]:my_awesome_app
    fetch = +refs/heads/*:refs/remotes/origin/*

You need to update the url; for example, I'm using github :) You can also add other remotesmanually. Tracking upstream branches will append their info to this file as well, for example

您需要更新网址;例如,我正在使用 github :) 您也可以remotes手动添加其他。例如,跟踪上游分支也会将它们的信息附加到此文件中

[branch "master"]
    remote = origin
    merge = refs/heads/master

which follows the above listing is how git manages tracking of remote branches. Hope this helps.

在上面的清单之后是 git 如何管理远程分支的跟踪。希望这可以帮助。

Cheers, Mike.

干杯,迈克。

回答by Mauvis Ledford

Any of those domains should work as long as they resolve to the same IP.

只要这些域中的任何一个解析为相同的 IP,它们都应该可以工作。