LoginSignup
8
8

More than 5 years have passed since last update.

Git LFSでデザインデータを管理できるか

Posted at

クアッド株式会社ではディレクターやデザイナーにもGithubを使ってもらっています。
始めは「わけがわからん」と言っていた彼らも、今では呼吸するようにGithubを使っています。
そこでしばしば聞かれるのは「デザインファイルもGithubで管理できないの?」という質問です。

Githubには1ファイル100MBまでの制限がありますし、プログラマからしたらそんな重いファイルいらないよと思うわけですが、実際やるとしたらどうなるのか見てみました。

環境は macOS Sierra です。

Git Large File Storage (LFS)

Githubに100MB超のファイルをpushするとエラーになりますが、その際「You may want to try Git Large File Storage」とおすすめしてくれています。

git-lfsなしの場合エラー
$ git push origin master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 20.24 MiB | 1.28 MiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: ecc47fd985ce90e8f3bd57addeca1642
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File hamburger.psd is 104.94 MB; this exceeds GitHub's file size limit of 100.00 MB
To https://github.com/kung-fu/gitlfs-sample2.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/kung-fu/gitlfs-sample2.git'

Git Large File Storage
https://github.com/git-lfs/git-lfs

Git Large File Storage はサイズの大きなファイルを扱うためのGitエクステンションです。

インストール

Homebrewでインストールします。

$ brew install git-lfs

セットアップ

git-lfsのインストール
$ git lfs install
Updated pre-push hook.
Git LFS initialized.

実行後 .git/lfs が作成されています。

対象ファイルの登録
$ git lfs track "*.psd"
Tracking *.psd

実行後 .gitattributes というファイルが作成され、対象ファイルが記録されます。

.gitattributes
$ cat .gitattributes 
*.psd filter=lfs diff=lfs merge=lfs -text

Githubにpush

100MB超のファイルを用意します。

$ ls -lh
-rw-r--r--@ 1 me  staff   105M 12 21 15:33 hamburger.psd
コミット
$ git add hamburger.psd
$ git commit -m "Add a large file."
[master 4c11668] Add a large file.
 1 file changed, 3 insertions(+)
 create mode 100644 hamburger.psd

それではGithubにpushしてみます。

git-lfsありの場合
$ git push origin master
Git LFS: (1 of 1 files) 104.94 MB / 104.94 MB                                                                                    
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 401 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/kung-fu/gitlfs-sample2.git
   6e2834f..4c11668  master -> master

git lfs を設定している場合、push が完了しました。

SorceTreeの場合

さて、ディレクター・デザイナーは SourceTree を使っているので、そちらではどのようになるのか確認します。

セットアップ

git lfs install はメニューバーの リポジトリ > Git LFS > リポジトリの初期化 から行います。

スクリーンショット 2016-12-21 16.12.46.png

同時に git lfs track にあたるトラック対象のファイルも登録可能です。(後からでも可能)

スクリーンショット 2016-12-21 16.13.40.png

コマンド実行した際と同じように .gitattributes が作成されます。
スクリーンショット 2016-12-21 16.13.50.png

push

100MBを超えるファイルをcommitしてpushしてみます。
スクリーンショット 2016-12-21 16.14.45.png

成功しました。
スクリーンショット 2016-12-21 16.18.25.png

終わりに

ここまでで使えなくもないかなと思ったのですが、こちらの記事で制限について説明してくださっています。

なおGitHubではリポジトリのサイズが1GBまでに制限されているのだが,この Git LFS の方は1アカウントにつき1GBまでと制限されている.

この記事を書くために100MBのファイルを4回ほどpushしたので、残り6回?
デザインデータの管理にガンガン使ったらあっという間にオーバーしそうですね。。。無理だ。。
ストレージにS3を利用するようにできそうではある。
https://github.com/meltingice/git-lfs-s3

開発の中でたまに発生するサイズの大きいファイルを管理するのには使えそうです。

8
8
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
8
8