You are browsing a read-only backup copy of Wikitech. The primary site can be found at wikitech.wikimedia.org

Git-lfs

From Wikitech-static
Jump to navigation Jump to search

"git large file storage" or git-lfs is a tool that helps with tracking large files inside a git repository while the file content is stored outside of git. The need for such functionality is necessitated by limitations in git performance which degrades as the size of the repository grows beyond a few megabytes. When storing files that are several hundred megabytes in size, git becomes prohibitively slow. git-lfsprovides one method of addressing this problem. Below you will find some tips on setting up git-lfs to work with Wikimedia projects and infrastructure.

git-lfs support in Gerrit

A few Wikimedia projects are beginning to experiment with using git-lfs to track large files associated with code that is hosted in Gerrit. Before git-lfs can be used it has to be enabled on the project's configuration in gerrit. Once lfs support is enabled, there are still a few more steps to use git-lfs.

Installing git-lfs client

To work with projects that use git-lfs, you need to download and install the git-lfs client on your workstation. The client can be downloaded from https://git-lfs.github.com/, simply follow the instructions under "Getting Started" on the git-lfs site.

Setting a http password in gerrit

In order to use git-lfs you will need to use your gerrit http username and password. This can be set in the gerrit settings under http-password. Even when you use ssh to access a git repository, git-lfs uses http(s) to transfer large files.

Setting lfs.url in your project's git config

You need to set the lfs.url for your project to point to the gerrit lfs url. To do this you need to run a command similar to the following, replacing {username} and {project/repository} with values appropriate for the project you are setting up.

# git config lfs.url 'https://{username}@gerrit.wikimedia.org/r/{project/repository}/info/lfs'

Git credential store

To ease the annoyance of git password prompts, the use of git's credential store makes it fairly painless.


libsecret

You can enable libsecret credential helper so that git can store your https credentials securely:

git config --global credential.helper libsecret
libgnome-keyring

This is apparently deprecated, but retained for posterity:

For Gnome users, the `git-credential-gnome-keyring` helper is an option which can be enabled fairly easily:

sudo apt-get install libgnome-keyring-dev
cd /usr/share/doc/git/contrib/credential/gnome-keyring
sudo make
git config --global credential.helper /usr/share/doc/git/contrib/credential/gnome-keyring/git-credential-gnome-keyring

Snippet by James Ward CC-BY-SA 3.0