[Git] GitHub と Bitbucket の Git LFS 対応状況
実務で利用できるか調査。
[markdown]
## 調査
以前に PSD ファイルのバージョン管理について検討した。
> * [.psd や .ai はどのようにバージョン管理すべきなのか | Deadwood](https://www.d-wood.com/blog/2014/10/06_6972.html)
### GitHub
その後、[GitHub](https://github.com/) が GitLFS に対応。
> * [Git Large File Storage v1.0](https://github.com/blog/2069-git-large-file-storage-v1-0)
無料で 1GB 分のサイズが提供されている。
毎月 $5 追加することで 50GB まで利用できるようになる模様。
直近の小規模サイト制作で受け取った PSD ファイルの総量を確認したところ 17GB であったので微妙なところ。
### Bitbucket
残念ながら Cloud サービスには対応していない。
が、Server (オンプレミス型) が、10 ユーザーまで $10 買い切りだった。
> * [Bitbucket – Pricing | Atlassian](https://ja.atlassian.com/software/bitbucket/pricing?tab=host-on-your-server)
適当な環境があれば、これを導入すると良いかも。
> Server (オンプレミス型) – 自分の環境にインストール
> – ファイヤーウォール内のお好きな環境にインストール
> – ライセンスは永久使用可能、保守(サポートとバージョンアップ)更新は1年単位
> – アプリケーションの完全なコントロール
> – 製品の細かいカスタマイズが可能
>
> [アトラシアン製品スタートガイド – アトラシアン パブリック スペース – Atlassian Japan Confluence](https://confluence.atlassian.co.jp/pages/viewpage.action?pageId=68288516)
対応 OS には、Mac OS X や Windows も含まれている。
## 使い方
GitHub で試してみる。
> * [Git Large File Storage](https://git-lfs.github.com/)
サンプルファイルとして、以下を利用する。
> * [コードベースのデザインに使用するAdobe Creative Cloud Extractのアセット | Adobe Creative Cloud tutorials](https://helpx.adobe.com/jp/creative-cloud/how-to/extract-assets-browser-workflow.html)
### インストール
こちらの書籍には GitLFS に関する記述があるよう。
売り上げランキング: 9,906
> * [エンジニアのためのGitの教科書 実践で使える!バージョン管理とチーム開発手法 – 太田智彬, 増田佳太, 山田直樹, 葛原佑伍, 大島雅人, 相野谷直樹, 株式会社リクルートテクノロジーズ, 株式会社リクルートマーケティングパートナーズ, 河村聖悟 – Google ブックス](https://books.google.co.jp/books?id=wMVeCwAAQBAJ&pg=PA162&lpg=PA162&dq=brew+install+git-lfs&source=bl&ots=8rTERpELTu&sig=0QFuBtprDw4nXaUIVm6T2J85NwQ&hl=ja&sa=X&ved=0ahUKEwj5wan83NjLAhVJkZQKHf84C9w4ChDoAQgbMAA#v=onepage&q=brew%20install%20git-lfs&f=false)
Homebrew で git-lfs をインストール。
“`prettyprinted
% brew install git-lfs
“`
`git init`
“`prettyprinted
% git init
Initialized empty Git repository in /Users/****/projects/sandbox-gitLFS/.git/
“`
extension をインストールし、.psd ファイルをトラックするように設定を行う。
“`prettyprinted
% git lfs install
Updated pre-push hook.
Git LFS initialized.
% git lfs track “*.psd”
Tracking *.psd
“`
.gitattributes に設定が書き込まれる。
“`:.gitattributes
*.psd filter=lfs diff=lfs merge=lfs -text
“`
### git push まで
“`prettyprinted
% git add .
% git commit -m ‘Add: Sample PSD file’
[master (root-commit) 992ef94] Add: Sample PSD file
2 files changed, 4 insertions(+)
create mode 100644 .gitattributes
create mode 100755 Adobe_PLAY_Comps.psd
% git push -u origin master
Git LFS: (1 of 1 files) 21.51 MB / 21.51 MB
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 444 bytes | 0 bytes/s, done.
Total 4 (delta 0), reused 0 (delta 0)
To git@github.com:DriftwoodJP/sandbox-gitlfs.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
“`
`git lfs` コマンドで色々確認できる模様。
“`prettyprinted
% git lfs help
git lfs
Git LFS is a system for managing and versioning large files in
association with a Git repository. Instead of storing the large files
within the Git repository as blobs, Git LFS stores special “pointer
files” in the repository, while storing the actual file contents on a
Git LFS server. The contents of the large file are downloaded
automatically when needed, for example when a Git branch containing
the large file is checked out.
Git LFS works by using a “smudge” filter to look up the large file
contents based on the pointer file, and a “clean” filter to create a
new version of the pointer file when the large file’s contents change.
It also uses a pre-push hook to upload the large file contents to
the Git LFS server whenever a commit containing a new large file
version is about to be pushed to the corresponding Git server.
Commands
——–
Like Git, Git LFS commands are separated into high level (“porcelain”)
commands and low level (“plumbing”) commands.
High level commands
——————–
* git lfs env:
Display the Git LFS environment.
* git lfs checkout:
Populate working copy with real content from Git LFS files
* git lfs fetch:
Download git LFS files from a remote
* git lfs fsck:
Check GIT LFS files for consistency.
* git lfs install:
Install Git LFS configuration.
* git lfs logs:
Show errors from the git-lfs command.
* git lfs ls-files:
Show information about Git LFS files in the index and working tree.
* git lfs pull:
Fetch LFS changes from the remote & checkout any required working tree files
* git lfs push:
Push queued large files to the Git LFS endpoint.
* git lfs status:
Show the status of Git LFS files in the working tree.
* git lfs track:
View or add Git LFS paths to Git attributes.
* git lfs untrack:
Remove Git LFS paths from Git Attributes.
* git lfs update:
Update Git hooks for the current Git repository.
Low level commands
——————-
* git lfs clean:
Git clean filter that converts large files to pointers.
* git lfs pointer:
Build and compare pointers.
* git lfs pre-push:
Git pre-push hook implementation.
* git lfs smudge:
Git smudge filter that converts pointer in blobs to the actual content.
“`
### GitHub 上での表示
プレビューが表示されている。
## 補遺
> * [サイズの大きいバイナリファイルを扱うための Git LFS 導入 | Numb.](http://wp.graphact.com/2015/10/04/setup-git-lfs)
> * [Git LFSが1.0になってGitHubで使えるようになったので試してみた – Qiita](http://qiita.com/kiida/items/0d51c43ac73f14f09f5a)
[/markdown]