Why do some repository URLs end in .git while others don't?

自闭症网瘾萝莉.ら 提交于 2019-11-28 19:08:46

The convention is that the .git extension should be used for bare repositories, and left off of directories with a working tree. Git doesn't really care, but has a few convenience methods that make this fairly transparent.

For example, if you have a repository named /tmp/foo.git and you call git clone file:///tmp/foo, Git will first try to find /tmp/foo. If it doesn't exist, it will try /tmp/foo.git instead.

This does not work the other way around. If your directory is named /tmp/foo and you try to clone from /tmp/foo.git you will be told:

fatal: '/tmp/foo.git' does not appear to be a git repository

Most of the HTTP/HTTPS functionality is from your web server, not Git. Even if you're using Smart HTTP transport, I suspect most of the magic happens in a server-side LocationMatch directive. Theory aside, some quick tests against GitHub show that it works the same way as the SSH and Git procotols in that respect, but your mileage may vary on other web servers.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!