バージョン管理システム

はじめに

Godot は VCS (Version Control System) フレンドリーであり、読み取り可能でマージ可能なファイルを生成することを目指しています。

バージョン管理用のプラグイン

Godot はエディタでのバージョン管理システムの使用をサポートしています。ただしエディタでバージョン管理を行うには、使用している特定の VCS 用のプラグインが必要です。

2023年7月現在、利用可能なのは Git プラグインのみですが、コミュニティが追加の VCS プラグインを作成する可能性があります。

公式Gitプラグイン

エディタ内から Git を使用することは、公式プラグインでサポートされています。最新のリリースは GitHub で見つけることができます。

Git プラグインの使用方法に関するドキュメントは、 wiki にあります。

VCS から除外するファイル

注釈

このリストは、Godot 4.1 以降のバージョン管理から無視する必要があるファイルとフォルダの一覧です。

Godot 3.x と Godot 4.0 では、バージョン管理から無視するファイルとフォルダのリストが 完全に 異なります。これは気を付ける必要があります。Godot 3.x と 4.0 では、機密性の高い資格情報が export_presets.cfg に保存される可能性があるからです (Godot 4.1 以降とは異なります)。

Godot 3 を使用している場合は、代わりにこのドキュメント ページの 3.5 バージョンを確認してください。

エディタでプロジェクトを初めて開いたときに、Godot によって自動的に作成されるファイルとフォルダがいくつかあります。生成されたデータでバージョン管理リポジトリが肥大化しないようにするには、それらを VCS ignore に追加する必要があります。

  • .godot/: このフォルダには、さまざまなプロジェクトキャッシュデータが保存されます。

  • *.translation: これらのファイルは、CSV ファイルから生成されバイナリインポートされた translations です。

プロジェクトを作成するとき、Godot プロジェクトマネージャーからバージョン管理用のメタデータを自動生成することができます。Git オプションを選択すると、プロジェクトルートに .gitignore ファイルと .gitattributes ファイルが作成されます。

プロジェクトマネージャーの [新しいプロジェクト] ダイアログでバージョン管理用のメタデータを作成する

プロジェクトマネージャーの 新しいプロジェクト ダイアログでバージョン管理用のメタデータを作成する

既存のプロジェクトでは、エディターの上部にある プロジェクト メニューから、バージョンコントロール > バージョン管理用メタデータの作成/上書き を選択します。これによりプロジェクトマネージャーから作成したものと同じファイルが作成されます。

Windows で Git を使用する

ほとんどの Git for Windows クライアントは、 core.autocrlftrue に設定されています。これによってファイルの改行コードが LF から CRLF に自動的に変換されるため、ファイルが Git によって不用意に変更済みとしてマークされる可能性があります。

このオプションは次のように設定することをお勧めします。

git config --global core.autocrlf input

プロジェクトマネージャーまたはエディターを使用してバージョン管理用メタデータを作成すると、 .gitattributes ファイルによって LF 改行コードが自動的に適用されます。この場合、 Git 設定を変更する必要はありません。

Git LFS

Git LFS (Large File Storage) is a Git extension that allows you to manage large files in your repository. It replaces large files with text pointers inside Git, while storing the file contents on a remote server. This is useful for managing large assets, such as textures, audio files, and 3D models, without bloating your Git repository.

注釈

When using Git LFS you will want to ensure it is setup before you commit any files to your repository. If you have already committed files to your repository, you will need to remove them from the repository and re-add them after setting up Git LFS.

It is possible to use git lfs migrate to convert existing files in your repository, but this is more in-depth and requires a good understanding of Git.

A common approach is setting up a new repository with Git LFS (and a proper .gitattributes), then copying the files from the old repository to the new one. This way, you can ensure that all files are tracked by LFS from the start.

To use Git LFS with Godot, you need to install the Git LFS extension and configure it to track the file types you want to manage. You can do this by running the following command in your terminal:

git lfs install

This will create a .gitattributes file in your repository that tells Git to use LFS for the specified file types. You can add more file types by modifying the .gitattributes file. For example, to track all GLB files, you can do this by running the following command in your terminal:

git lfs track "*.glb"

When you add or modify files that are tracked by LFS, Git will automatically store them in LFS instead of the regular Git history. You can push and pull LFS files just like regular Git files, but keep in mind that LFS files are stored separately from the rest of your Git history. This means that you may need to install Git LFS on any machine that you clone the repository to in order to access the LFS files.

Below is an example .gitattributes file that you can use as a starting point for Git LFS. 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.

# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf

# Git LFS Tracking (Assets)

# 3D Models
*.fbx filter=lfs diff=lfs merge=lfs -text
*.gltf filter=lfs diff=lfs merge=lfs -text
*.glb filter=lfs diff=lfs merge=lfs -text
*.blend filter=lfs diff=lfs merge=lfs -text
*.obj filter=lfs diff=lfs merge=lfs -text

# Images
*.png filter=lfs diff=lfs merge=lfs -text
*.svg filter=lfs diff=lfs merge=lfs -text
*.jpg filter=lfs diff=lfs merge=lfs -text
*.jpeg filter=lfs diff=lfs merge=lfs -text
*.gif filter=lfs diff=lfs merge=lfs -text
*.tga filter=lfs diff=lfs merge=lfs -text
*.webp filter=lfs diff=lfs merge=lfs -text
*.exr filter=lfs diff=lfs merge=lfs -text
*.hdr filter=lfs diff=lfs merge=lfs -text
*.dds filter=lfs diff=lfs merge=lfs -text

# Audio
*.mp3 filter=lfs diff=lfs merge=lfs -text
*.wav filter=lfs diff=lfs merge=lfs -text
*.ogg filter=lfs diff=lfs merge=lfs -text

# Font & Icon
*.ttf filter=lfs diff=lfs merge=lfs -text
*.otf filter=lfs diff=lfs merge=lfs -text
*.ico filter=lfs diff=lfs merge=lfs -text

# Godot LFS Specific
*.scn filter=lfs diff=lfs merge=lfs -text
*.res filter=lfs diff=lfs merge=lfs -text
*.material filter=lfs diff=lfs merge=lfs -text
*.anim filter=lfs diff=lfs merge=lfs -text
*.mesh filter=lfs diff=lfs merge=lfs -text
*.lmbake filter=lfs diff=lfs merge=lfs -text

For more information on Git LFS, check the official documentation: https://git-lfs.github.com/ and https://docs.github.com/en/repositories/working-with-files/managing-large-files.