2

Commonly seen on GitHub and here on SO (Import existing source code to GitHub):

git@github.com:/youruser/somename.git vs git@github.com:/youruser/somename

I accidentally added a git remote without the *.git extension and it worked fine. I only noticed it after pushing up a new branch.

Is there any need for the *.git extension?

Community
  • 1
  • 1
Brenden
  • 7,708
  • 11
  • 61
  • 75
  • [git docs](https://git-scm.com/docs/gitrepository-layout) mention a bare repo. They don't mention what the rules are how the extension is ignored/used when not using a bare repo. – gman Mar 07 '23 at 18:49

1 Answers1

2

No, you can skip the .git: the git repository hosting service (here GitHub, but you would find the same with gitolite, GitLab or Gitorious) usually knows how to find the full repository path from its name alone (without '.git')

git docs ("Git Repository Layout") mention a bare repo. They don't mention what the rules are how the extension is ignored/used when not using a bare repo

The Git URLs section of git clone actually references the directory created by a clone: xxx.git for a bare repo, xxx for a non-bare repository.
But only the implementation of git clone can explain why an URL with or without .git is authorized.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Is there any particular reason for the `.git`? – Brenden Oct 29 '14 at 20:03
  • @Brenden mainly convenience but also scripting: if you know the name of a repo, you don't want to have to think about adding an extension. That is what enable, for instance, the `go get github.com/username/reponame` command of the golang language: it will clone that repo, even without the extension. http://www.goinggo.net/2013/08/organizing-code-to-support-go-get.html – VonC Oct 29 '14 at 20:08