version_control_systems.rst 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. .. _doc_version_control_systems:
  2. Version control systems
  3. =======================
  4. Introduction
  5. ------------
  6. Godot aims to be VCS-friendly and generate mostly readable and mergeable files.
  7. Version control plugins
  8. -----------------------
  9. Godot also supports the use of version control systems in the editor itself.
  10. However, version control in the editor requires a plugin for the specific VCS
  11. you're using.
  12. As of July 2023, there is only a Git plugin available, but the community may
  13. create additional VCS plugins.
  14. Official Git plugin
  15. ~~~~~~~~~~~~~~~~~~~
  16. Using Git from inside the editor is supported with an official plugin.
  17. You can find the latest releases on
  18. `GitHub <https://github.com/godotengine/godot-git-plugin/releases>`__.
  19. Documentation on how to use the Git plugin can be found on its
  20. `wiki <https://github.com/godotengine/godot-git-plugin/wiki>`__.
  21. Files to exclude from VCS
  22. -------------------------
  23. .. note::
  24. This lists files and folders that should be ignored from version control in
  25. Godot 4.1 and later.
  26. The list of files of folders that should be ignored from version control in
  27. Godot 3.x and Godot 4.0 is **entirely** different. This is important, as Godot
  28. 3.x and 4.0 may store sensitive credentials in ``export_presets.cfg`` (unlike Godot
  29. 4.1 and later).
  30. If you are using Godot 3, check the ``3.5`` version of this documentation page
  31. instead.
  32. There are some files and folders Godot automatically creates when opening a
  33. project in the editor for the first time. To avoid bloating your version control
  34. repository with generated data, you should add them to your VCS ignore:
  35. - ``.godot/``: This folder stores various project cache data.
  36. - ``*.translation``: These files are binary imported
  37. :ref:`translations <doc_internationalizing_games>` generated from CSV files.
  38. You can make the Godot project manager generate version control metadata for you
  39. automatically when creating a project. When choosing the **Git** option, this
  40. creates ``.gitignore`` and ``.gitattributes`` files in the project root:
  41. .. figure:: img/version_control_systems_generate_metadata.webp
  42. :align: center
  43. :alt: Creating version control metadata in the project manager's New Project dialog
  44. Creating version control metadata in the project manager's **New Project** dialog
  45. In existing projects, select the **Project** menu at the top of the editor, then
  46. choose **Version Control > Generate Version Control Metadata**. This creates the
  47. same files as if the operation was performed in the project manager.
  48. Working with Git on Windows
  49. ---------------------------
  50. Most Git for Windows clients are configured with the ``core.autocrlf`` set to
  51. ``true``. This can lead to files unnecessarily being marked as modified by Git
  52. due to their line endings being converted from LF to CRLF automatically.
  53. It is better to set this option as:
  54. ::
  55. git config --global core.autocrlf input
  56. Creating version control metadata using the project manager or editor will
  57. automatically enforce LF line endings using the ``.gitattributes`` file.
  58. In this case, you don't need to change your Git configuration.
  59. Git LFS
  60. -------
  61. Git LFS (Large File Storage) is a Git extension that allows you to manage large
  62. files in your repository. It replaces large files with text pointers inside Git,
  63. while storing the file contents on a remote server. This is useful for
  64. managing large assets, such as textures, audio files, and 3D models, without
  65. bloating your Git repository.
  66. .. note::
  67. When using Git LFS you will want to ensure it is setup before you commit any files to your repository.
  68. If you have already committed files to your repository, you will need to
  69. remove them from the repository and re-add them after setting up Git LFS.
  70. It is possible to use ``git lfs migrate`` to convert existing files in your repository, but this is more in-depth and
  71. requires a good understanding of Git.
  72. A common approach is setting up a new repository with Git LFS (and a proper ``.gitattributes``), then
  73. copying the files from the old repository to the new one. This way, you
  74. can ensure that all files are tracked by LFS from the start.
  75. To use Git LFS with Godot, you need to install the Git LFS extension and
  76. configure it to track the file types you want to manage. You can do this by
  77. running the following command in your terminal:
  78. ::
  79. git lfs install
  80. This will create a ``.gitattributes`` file in your repository that tells Git to
  81. use LFS for the specified file types. You can add more file types by modifying
  82. the ``.gitattributes`` file. For example, to track all GLB files, you can do this by
  83. running the following command in your terminal:
  84. ::
  85. git lfs track "*.glb"
  86. When you add or modify files that are tracked by LFS, Git will automatically
  87. store them in LFS instead of the regular Git history. You can push and pull
  88. LFS files just like regular Git files, but keep in mind that LFS files are
  89. stored separately from the rest of your Git history. This means that you may
  90. need to install Git LFS on any machine that you clone the repository to in
  91. order to access the LFS files.
  92. Below is an example ``.gitattributes`` file that you can use as a starting point for Git LFS.
  93. These file types were chosen because they are commonly used, but you can modify the list to include any binary types you may have in your project.
  94. .. code-block:: gitignore
  95. # Normalize EOL for all files that Git considers text files.
  96. * text=auto eol=lf
  97. # Git LFS Tracking (Assets)
  98. # 3D Models
  99. *.fbx filter=lfs diff=lfs merge=lfs -text
  100. *.gltf filter=lfs diff=lfs merge=lfs -text
  101. *.glb filter=lfs diff=lfs merge=lfs -text
  102. *.blend filter=lfs diff=lfs merge=lfs -text
  103. *.obj filter=lfs diff=lfs merge=lfs -text
  104. # Images
  105. *.png filter=lfs diff=lfs merge=lfs -text
  106. *.svg filter=lfs diff=lfs merge=lfs -text
  107. *.jpg filter=lfs diff=lfs merge=lfs -text
  108. *.jpeg filter=lfs diff=lfs merge=lfs -text
  109. *.gif filter=lfs diff=lfs merge=lfs -text
  110. *.tga filter=lfs diff=lfs merge=lfs -text
  111. *.webp filter=lfs diff=lfs merge=lfs -text
  112. *.exr filter=lfs diff=lfs merge=lfs -text
  113. *.hdr filter=lfs diff=lfs merge=lfs -text
  114. *.dds filter=lfs diff=lfs merge=lfs -text
  115. # Audio
  116. *.mp3 filter=lfs diff=lfs merge=lfs -text
  117. *.wav filter=lfs diff=lfs merge=lfs -text
  118. *.ogg filter=lfs diff=lfs merge=lfs -text
  119. # Font & Icon
  120. *.ttf filter=lfs diff=lfs merge=lfs -text
  121. *.otf filter=lfs diff=lfs merge=lfs -text
  122. *.ico filter=lfs diff=lfs merge=lfs -text
  123. # Godot LFS Specific
  124. *.scn filter=lfs diff=lfs merge=lfs -text
  125. *.res filter=lfs diff=lfs merge=lfs -text
  126. *.material filter=lfs diff=lfs merge=lfs -text
  127. *.anim filter=lfs diff=lfs merge=lfs -text
  128. *.mesh filter=lfs diff=lfs merge=lfs -text
  129. *.lmbake filter=lfs diff=lfs merge=lfs -text
  130. For more information on Git LFS, check the official documentation:
  131. https://git-lfs.github.com/ and https://docs.github.com/en/repositories/working-with-files/managing-large-files.