github.com/x-oss-byte/git-lfs@v2.5.2+incompatible/docs/api/server-discovery.md (about) 1 # Server Discovery 2 3 One of the Git LFS goals is to work with supporting Git remotes with as few 4 required configuration properties as possible. Git LFS will attempt to use 5 your Git remote to determine the LFS server. You can also configure a custom 6 LFS server if your Git remote doesn't support one, or you just want to use a 7 separate one. 8 9 Look for the `Endpoint` properties in `git lfs env` to see your current LFS 10 servers. 11 12 ## Guessing the Server 13 14 By default, Git LFS will append `.git/info/lfs` to the end of a Git remote url 15 to build the LFS server URL it will use: 16 17 Git Remote: `https://git-server.com/foo/bar`<br> 18 LFS Server: `https://git-server.com/foo/bar.git/info/lfs` 19 20 Git Remote: `https://git-server.com/foo/bar.git`<br> 21 LFS Server: `https://git-server.com/foo/bar.git/info/lfs` 22 23 Git Remote: `git@git-server.com:foo/bar.git`<br> 24 LFS Server: `https://git-server.com/foo/bar.git/info/lfs` 25 26 Git Remote: `ssh://git-server.com/foo/bar.git`<br> 27 LFS Server: `https://git-server.com/foo/bar.git/info/lfs` 28 29 ## SSH 30 31 If Git LFS detects an SSH remote, it will run the `git-lfs-authenticate` 32 command. This allows supporting Git servers to give the Git LFS client 33 alternative authentication so the user does not have to setup a git credential 34 helper. 35 36 Git LFS runs the following command: 37 38 $ ssh [{user}@]{server} git-lfs-authenticate {path} {operation} 39 40 The `user`, `server`, and `path` properties are taken from the SSH remote. The 41 `operation` can either be "download" or "upload". The SSH command can be 42 tweaked with the `GIT_SSH` or `GIT_SSH_COMMAND` environment variables. The 43 output for successful commands is JSON, and matches the schema as an `action` 44 in a Batch API response. Git LFS will dump the STDERR from the `ssh` command if 45 it returns a non-zero exit code. 46 47 Examples: 48 49 The `git-lfs-authenticate` command can even suggest an LFS endpoint that does 50 not match the Git remote by specifying an `href` property. 51 52 ```bash 53 # Called for remotes like: 54 # * git@git-server.com:foo/bar.git 55 # * ssh://git@git-server.com/foo/bar.git 56 $ ssh git@git-server.com git-lfs-authenticate foo/bar.git download 57 { 58 "href": "https://lfs-server.com/foo/bar", 59 "header": { 60 "Authorization": "RemoteAuth some-token" 61 }, 62 "expires_in": 86400 63 } 64 ``` 65 66 Git LFS will output the STDERR if `git-lfs-authenticate` returns a non-zero 67 exit code: 68 69 ```bash 70 $ ssh git@git-server.com git-lfs-authenticate foo/bar.git wat 71 Invalid LFS operation: "wat" 72 ``` 73 74 ## Custom Configuration 75 76 If Git LFS can't guess your LFS server, or you aren't using the 77 `git-lfs-authenticate` command, you can specify the LFS server using Git config. 78 79 Set `lfs.url` to set the LFS server, regardless of Git remote. 80 81 ```bash 82 $ git config lfs.url https://lfs-server.com/foo/bar 83 ``` 84 85 You can set `remote.{name}.lfsurl` to set the LFS server for that specific 86 remote only: 87 88 ```bash 89 $ git config remote.dev.lfsurl http://lfs-server.dev/foo/bar 90 $ git lfs env 91 ... 92 93 Endpoint=https://git-server.com/foo/bar.git/info/lfs (auth=none) 94 Endpoint (dev)=http://lfs-server.dev/foo/bar (auth=none) 95 ``` 96 97 Git LFS will also read these settings from a `.lfsconfig` file in the root of 98 your repository. This lets you commit it to the repository so that all users 99 can use it, if you wish. 100 101 ```bash 102 $ git config --file=.lfsconfig lfs.url https://lfs-server.com/foo/bar 103 ```