Convert an existing git repository to lfs supported bitbucket repository

Hey there,

At the moment i am trying to convert a git repository into a lfs git repository on bitbucket. I am using the Bitbucket test server with the evaluation license. The source repository is self hosted by me. I already had a look at this guide from bitbucket, but its as detailed as needed. 

So far i enabled git lfs at the repository on the Bitbucket server.  Git-lfs is installed and i used git lfs track "*.jpg" inside the destination repository. After those settings i tryed to convert it like this: 

cd existing-project
git init
git add --all
git commit -m "Initial Commit"
git remote add origin http://User@localhost:7990/scm/dr/destination-repo.git
git push -u origin master

The repository got cloned. It works fine. But the git-lfs directory does not have any files in it. How can i successfully convert this, and how do i check if it worked ?

Would love to get some answers.

Chris 

2 answers

This widget could not be displayed.

Hi Christian,

In the list of commands you have included you did not list the git lfs track "*.jpg" command. You will need to run this after "git init" and before the "git add". I would suggest you then check your ".gitattributes" file to be sure it was updated by the "git lfs track" command.

Since you are running "git init" it is not clear to me if this is a new repository that you are pushing to Git, or if it is an existing repository you are trying to convert. The fact you use the "git init" command suggests the former, while the title of your post suggests the later.

Note that for an existing repository "git lfs track" will not alter any of the existing objects, only new files added with the "git add" command.

Converting an existing repository to use LFS for large objects can be achieved using one of two strategies:

  • Leave old content in plain Git and have new large files hosted in LFS storage
  • Migrate your entire repository, all history, by extracting all large objects and migrating them to LFS storage. This obviously requires re-writing Git history and thus has some implications

The Git LFS client itself is not capable of the second option, specifically not as a nice simple automatic operation. However I do see the BFG repo cleaner has added LFS support. I have not used it so can't say how effective it is.

Either way, I would suggest first getting familiar with Git LFS by playing with a simple test repository before considering any conversions options.

Regards,
Ben 

This widget could not be displayed.

Hi Christian,

You can use LFS Converter add-on for Bitbucket Server in order to migrate your existing Git repositories to LFS.

The instructions are as follows:

  1. Install LFS Converter into your Bitbucket Server instance.

  2. Go to repository you're going to convert.

  3. Click on Transfer files to LFS button.

  4. Scan repository and choose which file extensions to transfer to LFS.

  5. Click on Transfer button:

    step1.png

  6. When the plugin is done transferring files to LFS, click on Update References button in order to apply new history to your Git repository:

    step2.png

  7.  That's it! Now your Git repository is more compact as all the large files are moved to LFS storage. If you change your mind, you can easily revert the whole conversion back to the original state of Git repository:

    step3.png


Your question is rather old and, probably, you already have all your Git repositories migrated to LFS. But I believe this information might be helpful for many Bitbucket Server users as well.

Regards,
Semyon

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Aug 10, 2018 in Bitbucket

What is your #1 piece of advice to new users getting started using Bitbucket?

Hello Community! My name is Claire Maynard, and I’m a Product Marketing Manager on the Bitbucket team. I’m interested in hearing what advice or tips you have for new users getting started on ...

242 views 14 2
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you