Is it necessary to add `.git` after remote repo name?

Viewed 474

I am trying to push my local repo(set up on a CentOS server)to a remote empty repo initialized on GitLab. This is how I do it:

# 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

I met the RPC error described here

error: RPC failed; result=22, HTTP code = 404
fatal: The remote end hung up unexpectedly

I followed this answer and change the remote repo address:

git remote set-url origin http://remote/url/jdhao/some_repo.git

Now I can push the local repo to remote without error.

But for another local repo which is set up on my Windows machine, I can push it to a gitlab remote repo without adding .git after the repo name.

I wonder if there are some rules regarding this issue?

1 Answers

As referenced in the comment by @sakura-kinomoto .git suffix is a convention for bare repositories.

But, all repositories url on Gitlab & Github are working either with or without .git suffix.

You don't have to bother about this suffix if you're working with such development platforms.

Related