Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 
like image 589
user496949 Avatar asked Jun 17 '12 02:06

user496949


People also ask

What is .Git suffix?

The . git suffix is just convention to indicate that the directory in question is a bare git repository (ie, one in which there is no working copy).

Why is .Git so large?

As I told, git keeps track of each and every line change you made, it makes its history huge. But git uses a powerful compressing mechanism so that it will make all your codes to tiny tiny chunks. Also it stores the difference in between the files to reduce the size.

What is meant by repository URL?

A remote URL is Git's fancy way of saying "the place where your code is stored." That URL could be your repository on GitHub, or another user's fork, or even on a completely different server. You can only push to two types of URL addresses: An HTTPS URL like https://github.com/user/repo.git.

What does Git URL do?

When that Git clone command executes, the GitHub URL will be used to copy all of the remote files, along with the entire commit history, to the local developer machine. From there, a developer can perform as many local commits, fetch and push operations as they need.


1 Answers

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.

like image 148
Todd A. Jacobs Avatar answered Sep 22 '22 09:09

Todd A. Jacobs