2016年12月6日火曜日

Git LFSってのがあってじゃな

みなさんお疲れさまです. 田胡・柴田研究室AdventCalendar2016 6日目 の記事です. 担当はみんな思ってたよりしっかり書いてビビってるかとかいがお送りします. 今回はタイトル通りGit LFS について簡単に書いていこうかと思っとります. ## そもそもGit LFSとは? みなさんご存知GitHubがオープンソースとして公開しているもので,「Git Large File Storage」(FSなのにファイルシステムではない)と言います. 名前の通りGitやGitHubで,画像や動画などの大容量のファイル扱いやすくするものです. 昨年の10月に正式提供が発表され,GOlangで書かれてます. ## Git LFSの仕組み 通常のGitリポジトリとは別に Large File Storage というでかいファイル専用のサーバ(以下LFS)を用意します. そして設定した拡張子がpushされたら,Git内に大容量ファイルのテキストポインタのみ残してファイルの実体はLFSにぶち込んでいきます. リポジトリにファイルの実体がない為,圧迫せずに済みます. 仕組みとしては簡単そう... また,このLFSをGitHubは1GB無料で提供してます.(有料で50GB) ## 使ってみる ### インストール [公式](https://git-lfs.github.com/) からインストーラーとってきます. といいつつ私は brew install git-lfs で入れました. インストールが終わったらターミナルでも開いて,以下のコマンドを実行します. ```bash $ git lfs install Git LFS initialized. ``` ### 設定していく まずはテキトーにGitHubのリポジトリを用意してください. 次に LFS で管理させるファイルタイプを設定します. 今回はわかりやすく 「jpg」と「zip」を登録します. ```bash $ git lfs track "*.jpg" $ git lfs track "*.zip" $ git lfs track Listing tracked paths *.jpg (.gitattributes) *.zip (.gitattributes) ``` 登録された情報は .gitattributes に格納されてます. ### 試してみる それでは登録した拡張子のテキトーなファイルをコミットします. この辺は普段通りです. ```bash $ git add .gitattributes $ git add test.jpg $ git commit -m 'LFS test' ``` LFSの管理になったか確認するには以下のコマンドを使います. ```bash $ git lfs ls-files 2e8fa3ded6 * test.jpg ``` うまくいってればハッシュ値とファイル名が表示されるはずです. GitHub上なのでこのままpushすればLFSに自動で上がっていくはず...(実はgitlabで試してるからこの先未検証) せっかく無料なGitHubに1GBつかっちゃおうね〜 ## まとめ 遠くない未来,田胡研インフラに導入していくはずの技術の1つになります. これがちゃんと機能すれば動画や画像もgitで管理できる...たぶん便利!! その為にはgitlabの更新などまだまだ問題山積みです. そんなこんなで簡単なGit LFSの紹介でした.(後で追記したい) おわり ## 次~~ 誰もいないっぽいから先頭もどってすかい氏にお願いします.

7 件のコメント:

  1. These are good for storage purposes especially for students who have a bulk of assignments and want to keep them all so that they can benefit from them in the future. I get finance assignment help and want a place to store my assignments.

    返信削除
  2. Your blog always had some incredible piece of content. I am here to give the amazon discount code I hope you like it.

    返信削除
  3. This is quite a good blog. Keep sharing. I love them. Are you also searching for writing assignments for nursing students we are the best solution for you. We are best known for delivering nursing paper writing services to students without having to break the bank.

    返信削除
  4. This is quite a good blog. Keep sharing. I love them. Are you also searching for case writing center ? we are the best solution for you. We are best known for delivering nursing paper writing services to students without having to break the bank.

    返信削除
  5. BCBG Coupon Code is the best way to avail discounts on BCBG Coupons store shopping, there are lots of items on which you can avail the discount, amazing offers so visit the store by clicking the button and Save your Pocket now!

    返信削除
  6. HealthPost Coupons code is best code provided by HealthPost . Amazing Discount Offers, Get HealthPost & Promo Codes and save up to 45% on the offer, so get the code helps you to save on coupon and promo codes.

    返信削除
  7. Passing your driving test is a major milestone in life, and with Driving Test Success, you can achieve this goal with confidence. And with their latest driving test success discount codes, you can save money on their top-rated products to help you pass the test on the first try.

    返信削除