How do I get more info on files in Git LFS shared storage

お困りですか?

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

コミュニティに質問

目的

When files are tracked with Git LFS, they are stored in an embedded LFS object store on the Bitbucket Server host machine.

Since all repositories share this object store, it can be useful to know how to trace the hash that represents the stored object back to:

  • the repository it is associated with
  • the commit hash associated with the object
  • the information about the file being tracked by Git LFS

This guide will outline steps to gather these items.


ソリューション

  1. On the Bitbucket Server host machine, go to the $BITBUCKET_HOME/shared/data/git-lfs/storage location. This directory should contain a number of subdirectories with character strings for names, eg. d9a89a25acb91c5e3289.
  2. In the subdirectory, there will be another subdirectory with a 2 character string name, eg. ec and in that directory there should be a file with a long string for the name, eg e19c6a918a8a8079d1957c89622784908732c2e86696d6fc98bfc31c71f6c5.
  3. When you combine the 2nd subdir name (ec) with the file name (e19c6a918a8a8079d1957c89622784908732c2e86696d6fc98bfc31c71f6c5) you have the oid that the pointer in the repository uses to retrieve the git lfs tracked file when the repository is cloned, eg. ece19c6a918a8a8079d1957c89622784908732c2e86696d6fc98bfc31c71f6c5. 

  4. From the repository's location on disk you can run the following git log to get information regarding the file being tracked by git lfs: 

    root@stash0:/var/atlassian/application-data/bitbucket/shared/data/repositories/13# git log --all -p -S ece19c6a918a8a8079d1957c89622784908732c2e86696d6fc98bfc31c71f6c5
    commit 9e237c1f25499e4f7a4c31774aa81e99da742a99
    Author: Nathaniel Hansberry <nhansberry@atlassian.com>
    Date:   Tue Apr 11 09:54:18 2017 -0500
    
        Added an image
    
    diff --git a/bf.jpg b/bf.jpg
    new file mode 100644
    index 0000000..e21a255
    --- /dev/null
    +++ b/bf.jpg
    @@ -0,0 +1,3 @@
    +version https://git-lfs.github.com/spec/v1
    +oid sha256:ece19c6a918a8a8079d1957c89622784908732c2e86696d6fc98bfc31c71f6c5
    +size 57364

    If the repository ID is unknown we can move to the $BITBUCKET_HOME/shared/data/repositories directory and use the command above in a for loop to find the associated repository: 

    for i in `ls`;do echo $i; cd $i; git log --all -p -S ece19c6a918a8a8079d1957c89622784908732c2e86696d6fc98bfc31c71f6c5; cd -;done

    The number preceding the git log info is the repository ID.

  5. From the $BITBUCKET_HOME/shared/data/repositories we can use the find command and the commit hash (minus the first 2 characters) to get the path to the pointer that is actually located in the repository: 

    root@stash0:/var/atlassian/application-data/bitbucket/shared/data/repositories# find . -name 237c1f25499e4f7a4c31774aa81e99da742a99
    ./13/objects/9e/237c1f25499e4f7a4c31774aa81e99da742a99




最終更新日 2018 年 11 月 2 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.