Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

What is the order of events when implementing Git LFS on a existing Bitbucket repo?

Chris Fouts June 22, 2018

I have an existing non Git-LFS repo that I want to implement Git LFS on and I'm reading https://confluence.atlassian.com/bitbucket/use-git-lfs-with-existing-bitbucket-repositories-829078749.html. What is the order of events? Do I...

  • Install Git LFS on laptip
  • Clone existing repo
  • cd to local repo dir
  • run "git lfs install"
  • run "git lfs track *.ext"
  • git commit

Then follow the instructions on BFG? https://confluence.atlassian.com/bitbucket/use-bfg-to-migrate-a-repo-to-git-lfs-834233484.html

It's NOT clear from the links WHEN to convert the existing repo to use Git LFS

1 answer

1 accepted

0 votes
Answer accepted
Mikael Sandberg
Community Champion
June 22, 2018

Hi Chris,

Welcome to the Atlassian Community.

The order of events should be:

  1. Download Git LFS
  2. Install Git LFS using git lfs install
  3. Clone and cd into your repository
  4. Set which files to track with git lfs track
  5. Commit the changes made to .gitattribute
  6. Run BFG to change the Git history
Chris Fouts June 22, 2018

In step #5, are the Git LFS objects created then? Thanks!

Mikael Sandberg
Community Champion
June 22, 2018

No, it just tells Git that files with that extension will be handled by LFS, the actual conversion happens when you run BFG for existing files. If you do not run BFG, existing file would not be handled by LFS.

Chris Fouts June 22, 2018

So the BFG step (#6) is run in a clone mirror (git clone --mirror) which is a bare repo, at least per https://confluence.atlassian.com/bitbucket/use-bfg-to-migrate-a-repo-to-git-lfs-834233484.html?_ga=2.229845012.96814952.1529633258-482757227.1527186133. I'm missing on WHEN the Git LFS objects are created. Thanks again!

Chris Fouts June 22, 2018

After I ran BFG on my mirror clone, I did a git push origin --force, per the BFG link, and I do NOT see any Git LFS objects on my repo in Bitbucket.

Mikael Sandberg
Community Champion
June 22, 2018

The objects are created when you push the converted repository back, step 5 in the link above. Note that if you have already run the git lfs install, you can skip step 4.

Chris Fouts June 22, 2018

And a subsequent clone of the repo gives...

Downloading MarcomLite/lib/jets3t-0.6.1/cockpit-0.6.1.jar (144 KB)

Error downloading object: MarcomLite/lib/jets3t-0.6.1/cockpit-0.6.1.jar (716be41): Smudge error: Error downloading MarcomLite/lib/jets3t-0.6.1/cockpit-0.6.1.jar (716be4107b362e413dc1ae29dc88e9b79e680def2c725ecc2d73268c4ea66e75): [716be4107b362e413dc1ae29dc88e9b79e680def2c725ecc2d73268c4ea66e75] Object does not exist on the server: [404] Object does not exist on the server

What am I missing?
 

Mikael Sandberg
Community Champion
June 22, 2018

Hmm, sounds like something failed during the conversion, have a look at this troubleshooting guide. You should be able to see the file when you navigate to it in Bitbucket or locally in your repository.

Chris Fouts June 22, 2018

None of the cases applied to me, i.e., I didn't get any errors.

Mikael Sandberg
Community Champion
June 22, 2018

If everything went as expected the files handled by LFS will show up as regular files in the repository. 

Chris Fouts June 22, 2018

The "error" (it seems to me anyway) was with the instructions of the BFG page, where it tells you to

  • git clone --mirror
  • run bfg*.jar on the mirrored clone
  • git push origin --force

I ran bfg on a non-mirror clone and all worked. Because if you think about it, how can you create objects on a "bare" repo?

But I still feel like I'm missing something.

Mikael Sandberg
Community Champion
June 22, 2018

When I ran it I used these steps, comparing them to what is in the Bitbucket docs the thing missing is the garbage collection before the push, but normally Bitbucket does its own gc when you push anything to it.

Chris Fouts June 22, 2018

I take this back, I still have git clone errors, Git LFS objects does not exist on the server!

Though I see Git LFS files on the BB GUI

Downloading MarcomLite/lib/jets3t-0.6.1/cockpit-0.6.1.jar (144 KB)

Error downloading object: MarcomLite/lib/jets3t-0.6.1/cockpit-0.6.1.jar (716be41): Smudge error: Error downloading MarcomLite/lib/jets3t-0.6.1/cockpit-0.6.1.jar (716be4107b362e413dc1ae29dc88e9b79e680def2c725ecc2d73268c4ea66e75): [716be4107b362e413dc1ae29dc88e9b79e680def2c725ecc2d73268c4ea66e75] Object does not exist on the server: [404] Object does not exist on the server

 

On my local repo I ran BFG against

$ git show HEAD:MarcomLite/lib/jets3t-0.6.1/cockpit-0.6.1.jar

version https://git-lfs.github.com/spec/v1

oid sha256:716be4107b362e413dc1ae29dc88e9b79e680def2c725ecc2d73268c4ea66e75

size 143768

 

$ ls .git/lfs/objects/71/6b

716be4107b362e413dc1ae29dc88e9b79e680def2c725ecc2d73268c4ea66e75

Chris Fouts June 22, 2018

I take this back, I still have git clone errors, Git LFS objects does not exist on the server!

Though I see Git LFS files on the BB GUI

Downloading MarcomLite/lib/jets3t-0.6.1/cockpit-0.6.1.jar (144 KB)

Error downloading object: MarcomLite/lib/jets3t-0.6.1/cockpit-0.6.1.jar (716be41): Smudge error: Error downloading MarcomLite/lib/jets3t-0.6.1/cockpit-0.6.1.jar (716be4107b362e413dc1ae29dc88e9b79e680def2c725ecc2d73268c4ea66e75): [716be4107b362e413dc1ae29dc88e9b79e680def2c725ecc2d73268c4ea66e75] Object does not exist on the server: [404] Object does not exist on the server

 

On my local repo I ran BFG against

$ git show HEAD:MarcomLite/lib/jets3t-0.6.1/cockpit-0.6.1.jar

version https://git-lfs.github.com/spec/v1

oid sha256:716be4107b362e413dc1ae29dc88e9b79e680def2c725ecc2d73268c4ea66e75

size 143768

 

$ ls .git/lfs/objects/71/6b

716be4107b362e413dc1ae29dc88e9b79e680def2c725ecc2d73268c4ea66e75

Mikael Sandberg
Community Champion
June 22, 2018

I went back and checked my notes I created when doing this and after I ran the gc on the repository, I also did git lfs init on it:

BFG rewrites history, extracting files to lfs/objects and adding .gitattributes for LFS tracking. Now we need to strip out the large files,run a garbage collection and enable Git LFS on the repository.

git reflog expire --expire=now --all && git gc --prune=now
git lfs init
Chris Fouts June 22, 2018

I take this back, I still have git clone errors, Git LFS objects does not exist on the server!

Though I see Git LFS files on the BB GUI

Downloading MarcomLite/lib/jets3t-0.6.1/cockpit-0.6.1.jar (144 KB)

 Object does not exist on the server: [404] Object does not exist on the server

 

On my local repo I ran BFG against

$ git show HEAD:MarcomLite/lib/jets3t-0.6.1/cockpit-0.6.1.jar

version https://git-lfs.github.com/spec/v1

oid sha256:716be4107b362e413dc1ae29dc88e9b79e680def2c725ecc2d73268c4ea66e75

size 143768

 

$ ls .git/lfs/objects/71/6b

716be4107b362e413dc1ae29dc88e9b79e680def2c725ecc2d73268c4ea66e75

Chris Fouts June 22, 2018

There's no git lfs init

Mikael Sandberg
Community Champion
June 22, 2018

git lfs init has been replace by git lfs install.

After you pushed the bare repository back to Bitbucket, did you make a new local clone or just continued using your old repository? It is recommended to delete the old clone and create a new one, since your old clone still thinks that your files that was just converted are still stored within the repository instead of handled via LFS.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events