LoginSignup
20
10

More than 5 years have passed since last update.

UnityプロジェクトをGitHubで管理するためのシンプルな初期設定

Posted at

UnityプロジェクトをGitHubで管理します。
書いてみるとどうということはないですが、少しひっかかったのでまとめました。

Unityでプロジェクトを作成

まずはふつうにUnityでプロジェクトを作成します。
UnityHubから[新規]で適当なプロジェクト名を入力して作成。

image.png

しばらくするとUnityが立ち上がるので
[Edit]->[ProjectSettings]で
Version ControlがVisible Meta Files
Asset SerializationがForce Textになっているのを確認。

image.png

Unityの操作はこれだけです。

GitHubでリモートリポジトリを作成

GitHubのサイトへいき、リポジトリ新規作成ページから、リポジトリを作ります。
この際、[Add .gitignore]のプルダウンで[Unity]を選択してください。(重要)
[Initialize this repository with a README]のチェックはしなくてかまいません。

image.png

ローカルリポジトリを作る

次に、ローカルリポジトリを作るため、コマンドラインツールで先程つくったUnityプロジェクトのフォルダ階層に移動し

git init
git remote add origin [リモートリポジトリのURL]

で、ローカルリポジトリとリモートリポジトリをリンクします。

.gitignoreをローカルに追加する

通常であれば、ここからaddcommitpushして完了ですが、
このままだとUnityプロジェクト内の不必要なファイルまでコミットしてしまうため、
リモートリポジトリで自動生成された.gitignoreをローカルリポジトリに追加します。

git pull origin master

そのまま通常通り、addcommitpushします。

git add .
git commit -m "first commit."
git push origin master

作成したUnityプロジェクトがリモートリポジトリに反映されていたら完了です。

image.png

20
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
10