5

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?

jdhao
  • 24,001
  • 18
  • 134
  • 273
  • 5
    No, this is just a naming convention that not everybody follows. The usual convention is that if the name is followed by .git, it is a "bare" repository, but this is also not always followed. – Lasse V. Karlsen Dec 20 '18 at 11:56
  • Probably, you didn't have these issue on windows because your windows client are adding .git directly. At least on gitlab, .git is a must. – Sakura Kinomoto Dec 22 '18 at 14:16
  • @SakuraKinomoto No, windows client did not add `.git`. Do you have any reference that `.git is a must on gitlab`? – jdhao Dec 24 '18 at 02:39
  • I'm talking about adding it when sending request only. On gitlab, the folders itself who have the repositories have the .git extension. It's safe to assume it's neccesary, at least using ssh. – Sakura Kinomoto Dec 24 '18 at 03:09

1 Answers1

0

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.

Degan
  • 989
  • 2
  • 16
  • 30
mab
  • 378
  • 1
  • 8