Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the different git :// and git+https://?

Tags:

git

node.js

I want to add a git repository to my package.json.

{
    "dependencies": {
        "dep1": "git+https://url1",
        "dep2": "git://url1"        
}

When I run dep1 it worked for and dep2 failed. What is the diffrerent between git+https and git://? Does it is the same result ? Do I need to add something to .git?

like image 452
user1365697 Avatar asked Nov 01 '25 17:11

user1365697


1 Answers

There are several protocols you can use to reference your dependencies in package.json:

git, git+ssh, git+http, git+https and git+file

As always, there are pros and cons of all of the protocols.

The difference is that with git: you're using the native git protocol and with git+https: you're accessing a git repo over HTTPS (you could also use SSH instead of HTTPS, for example, but the server needs to support it).

The git protocol is very fast but it lacks authentication or encryption.

The git+https is nice for public repos and it works well with proxies and firewalls but if you need authentication then you need to provide username and password.

The git+ssh is good for private repos because it uses your ssh public keys for authentication and no passwords need to be entered.

The git+file is for referencing repos on your own filesystem, usually local files but it can also be used with remote files with SMB or NFS.

Now, if you want to change git+http to git then it will work only if you have a git server installed and listening on the same host and serving the same repos.

It's like changing http: to ftp: in a URL - it will work only if you have an FTP server installed on the same host and serving the same files.

The bottom line is that you can use only those protocols that the server supports.

See the docs:

  • https://docs.npmjs.com/cli/install
  • https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols
like image 79
rsp Avatar answered Nov 04 '25 09:11

rsp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!