63

When I clone a repository, is there any difference between these two URLs?

  1. Without .git extension:

    git clone http://foo/repo
    
  2. With .git extension:

    git clone http://foo/repo.git
    
Todd A. Jacobs
  • 81,402
  • 15
  • 141
  • 199
user496949
  • 83,087
  • 147
  • 309
  • 426
  • 1
    if you are referring to Github URLs the .git is optional – NDBoost Jun 17 '12 at 03:14
  • 8
    You might be interested in [this](http://stackoverflow.com/a/1734421/164966) answer. Specifically *The naming convention of reponame.git is usually reserved for bare repositores ...* – Roman Jun 17 '12 at 04:52

1 Answers1

52

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.

Todd A. Jacobs
  • 81,402
  • 15
  • 141
  • 199
  • 1
    I thought that the smart http capability was a wrapper on the git side, so that the server side is simply providing an HTTP response. https://github.com/blog/642-smart-http-support but http://www.kernel.org/pub/software/scm/git/docs/v1.7.3/git-http-backend.html suggest I was wrong and it is a bit of server functionality. – Philip Oakley Jun 17 '12 at 19:41