When I clone a repository, is there any difference between these two URLs?
Without .git extension:
git clone http://foo/repo
With .git extension:
git clone http://foo/repo.git
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).
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With