是否有必要在远程回购名称后添加`.git`?

jdh*_*hao 5 git gitlab

我试图将我的本地仓库(在CentOS服务器上设置)推送到在GitLab上初始化的远程空仓库.我是这样做的:

# initialize a repo on local
git init

git config --global user.name jdhao
git config --global user.email jdhao@xxxxx.com

# add all file in local repo
git add . 

# commit the changes
git commit -m "first commit"

# add a remote repo
git remote add origin http://remote/url/jdhao/some_repo

# push change local change to remote repo    
git push -u origin master
Run Code Online (Sandbox Code Playgroud)

我遇到了这里描述的RPC错误:

错误:RPC失败; 结果= 22,HTTP代码= 404
致命:远程端意外挂断

我按照这个答案更改了远程仓库地址:

git remote set-url origin http://remote/url/jdhao/some_repo.git
Run Code Online (Sandbox Code Playgroud)

现在我可以将本地仓库推送到远程而不会出错.

但是对于在我的Windows机器上设置的另一个本地仓库,我可以将其推送到gitlab远程仓库,而无需.git在回购名称后添加.

我想知道这个问题是否有一些规则?

mab*_*mab 0

正如@sakura-kinomoto 的评论中所引用的,.git后缀是裸存储库的约定。

但是,Gitlab 和 Github 上的所有存储库 URL 都可以使用或不使用.git后缀。

如果您使用此类开发平台,则不必担心此后缀。