git-lfs.mdx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. ---
  2. title: "Git LFS"
  3. description: "Managing large binary files with some magic"
  4. icon: "file-arrow-up"
  5. ---
  6. Git Large File Storage (LFS) helps manage large binary files in Git repositories. Instead of storing large files directly in the repository, Git LFS replaces them with lightweight pointers while storing the actual file contents on a separate server.
  7. ## How it works
  8. The Git LFS client communicates with the Gogs server over HTTP/HTTPS. It uses HTTP Basic Authentication to authorize client requests. Once a request is authorized, the Git LFS client receives instructions on where to fetch or push the large file.
  9. ## Server configuration
  10. Git LFS works out of the box with the default configuration for any supported version of Gogs.
  11. All configuration options for Git LFS are located in the `[lfs]` section of `custom/conf/app.ini`:
  12. ```ini
  13. [lfs]
  14. ; The storage backend for uploading new objects.
  15. STORAGE = local
  16. ; The root path to store LFS objects on the local file system.
  17. OBJECTS_PATH = data/lfs-objects
  18. ```
  19. | Option | Default | Description |
  20. |---|---|---|
  21. | `STORAGE` | `local` | The storage backend for LFS objects. Currently only `local` is supported. |
  22. | `OBJECTS_PATH` | `data/lfs-objects` | The root path on the local file system where LFS objects are stored. |
  23. ## Version requirements
  24. To use Git LFS with your Gogs instance, you need:
  25. - Gogs version **0.12** or later
  26. - [Git LFS client](https://git-lfs.github.com/) version **1.0.1** or later
  27. ## Using Git LFS
  28. Git LFS endpoints in a Gogs server are automatically discovered by the Git LFS client, so you do not need to configure anything upfront.
  29. <Steps>
  30. <Step title="Install Git LFS">
  31. Install the [Git LFS client](https://git-lfs.github.com/) on your machine. Most package managers include it:
  32. ```bash
  33. # macOS
  34. brew install git-lfs
  35. # Debian/Ubuntu
  36. sudo apt install git-lfs
  37. # Then initialize Git LFS
  38. git lfs install
  39. ```
  40. </Step>
  41. <Step title="Track large files">
  42. In your repository, tell Git LFS which file patterns to track:
  43. ```bash
  44. git lfs track "*.psd"
  45. git lfs track "*.zip"
  46. ```
  47. This creates or updates a `.gitattributes` file. Make sure to commit it:
  48. ```bash
  49. git add .gitattributes
  50. git commit -m "Track large files with Git LFS"
  51. ```
  52. </Step>
  53. <Step title="Push as usual">
  54. Add, commit, and push your files normally. Git LFS will automatically handle the large files:
  55. ```bash
  56. git add design.psd
  57. git commit -m "Add design file"
  58. git push origin main
  59. ```
  60. </Step>
  61. </Steps>
  62. For a complete walkthrough, see the official [Git LFS Tutorial](https://github.com/git-lfs/git-lfs/wiki/Tutorial).
  63. ## Known limitations
  64. <Warning>
  65. Be aware of the following limitations when using Git LFS with Gogs.
  66. </Warning>
  67. <AccordionGroup>
  68. <Accordion title="No S3 or object storage support">
  69. Only local storage is supported. All LFS objects are stored on the same server where Gogs runs. Support for Object Storage Services like Amazon S3 is being tracked in [gogs/gogs#6065](https://github.com/gogs/gogs/issues/6065).
  70. </Accordion>
  71. <Accordion title="SSH remotes use HTTP for LFS transfers">
  72. When SSH is set as a remote, Git LFS objects still go through HTTP/HTTPS. Any Git LFS request will prompt for HTTP/HTTPS credentials, so a good Git credentials store is recommended.
  73. </Accordion>
  74. <Accordion title="No file locking support">
  75. File locking is not supported. This feature is being tracked in [gogs/gogs#6064](https://github.com/gogs/gogs/issues/6064).
  76. </Accordion>
  77. </AccordionGroup>