Bitbucket is getting a new navigation

We’re rolling out these changes, so the documentation may not match your experience in the Bitbucket Cloud app. Read about the new Bitbucket navigation

Bitbucket で Git LFS を使用する

Bitbucket Cloud supports the Large File Storage (LFS) extension for Git that speeds up the handling of large files. It does this by replacing those large files in your Git repository with text pointer files – the pointers reference the large files, which are actually stored on a remote server. Read more about Git Large File Storage in Bitbucket.

The amount of Git LFS storage you have depends on your Bitbucket Bucket Cloud plan. To see the pricing for the various plans, check out our Bitbucket Cloud pricing page. Get started with Git LFS by completing these steps, described on this page:

このページに記載されたステップを完了したら、通常の操作と同様に、Git とリポジトリで作業を続行できます。LFS ファイル処理は自動的に行われるため、特別なアクションは不要です。

Git LFS の検証には、Bitbucket 内の新しいリポジトリを使用することをおすすめします。これは、既存のリポジトリのコピーでもかまいません。本番環境で使用しているリポジトリは、LFS の検証に使用しないでください。

1. 新しいリポジトリとクローンを作成する 

Go to your account in Bitbucket and create and clone a new repo in the usual way.

Bitbucket で Git LFS を検証する際は、本番環境やプロジェクトのリポジトリで予期しない結果が発生することを防ぐために、新しいリポジトリを使用することをおすすめします。

2. Git LFS クライアントをローカルにインストールする

Git LFS を使用するすべてのユーザーが、ローカル マシンにクライアントをインストールする必要があります。この操作は一度のみ行います。

git --version コマンドを使用して、Git 1.8.2 以降を使用していることを確認します。

Git LFS クライアントをインストールします。

  • For Linux and Mac OS X, use a package manager to install git-lfs, or download from here

  • On Windows, download the installer from here, and run it. 

ターミナルまたはコマンド プロンプトで次のコマンドを実行します。

git lfs install

これにより、ホーム ディレクトリの .gitconfig ファイルに LFS フィルタが追加され、すべてのリポジトリで利用できるようになります。LFS を特定のリポジトリでのみ使用したい場合、git lfs install --local を使用します。

3. Git LFS ファイルのトラッキングをローカルにセットアップする

Git LFS を使用する各リポジトリでトラッキングをセットアップする必要があります。

ローカル マシンで次の操作を行います。

  1. Git LFS を使用したいリポジトリにディレクトリを切り替えて、次のコマンドを実行します。

    git lfs track '<pattern>'

    次のような <pattern> を使用して照合できます。

    • path/to/some/folders/*" などの、フォルダへのパス (複数可)

    • bckgrnd.bin、"*.psd""、"*.*" などの、特定のファイル名またはファイル タイプ。ワイルドカードを使用する場合、shell に展開されるのを防ぐために二重引用符で囲む必要があります。

    複数のパターンを追加できます。追跡されているすべてのパターンを確認するには、git lfs track コマンドを引数なしで使用します。パターンはリポジトリの .gitattributes ファイルに追加されます。 

  2. .gitattributes ファイルへの変更を通常の手順でコミットおよびプッシュします。

    git add .gitattributes git commit -m "add Git LFS to the repo" git push origin main

    変更をプッシュすると、リポジトリをクローンしたすべてのユーザーにトラッキング パターンが適用されます。トラッキングを変更した場合はこの手順を行うことをおすすめします。

4. LFS ファイルを Bitbucket へプッシュする

これで、<pattern> に一致するファイル名を持つファイルを追加すると、自動的に LFS によって処理されるようになりました。

git add <someLFSfilename> git commit -m "Add LFS file" git push origin main

Want more? Read our in-depth tutorial about Git LFS and how to use it

さらにヘルプが必要ですか?

アトラシアン コミュニティをご利用ください。