ii git-annex 8.20210223-2ubuntu2
according to the document
Once you've told git-annex what files are large, both git annex add and git add/git commit -a will add the large files to the annex and the small files to git.
then I have .gitattributes
*.gz annex.largefiles=(largerthan=0)
*.tar annex.largefiles=(largerthan=0)
*.zip annex.largefiles=(largerthan=0)
*.bin annex.largefiles=(largerthan=50mb)
When I do git annex add *.gz
it change all the file into symlink
however when I do git add *.gz
, I hope it does the same. But instead, it copy all the file into .git/annex but does not create symlink.
What did I do wrong here?
ii git-annex 8.20210223-2ubuntu2
according to the document
Once you've told git-annex what files are large, both git annex add and git add/git commit -a will add the large files to the annex and the small files to git.
then I have .gitattributes
*.gz annex.largefiles=(largerthan=0)
*.tar annex.largefiles=(largerthan=0)
*.zip annex.largefiles=(largerthan=0)
*.bin annex.largefiles=(largerthan=50mb)
When I do git annex add *.gz
it change all the file into symlink
however when I do git add *.gz
, I hope it does the same. But instead, it copy all the file into .git/annex but does not create symlink.
What did I do wrong here?
Share Improve this question asked Mar 9 at 21:19 WangWang 8,2725 gold badges48 silver badges78 bronze badges2 Answers
Reset to default 1If the operation created an object under .git/annex/objects/
, then the command works as advertised and has added it into the annex.
Files handled by the git-annex git add
filter are added as unlocked, as documented under the annex.addunlocked
setting. (In part because, as far as I remember, a smudge/clean filter cannot replace the original with a different type in the first place.) See man git-annex unlock
.
Instead of a symlink, the smudge/clean filter stores the Git object as a special text file starting with /annex/...
, which you can see using git show HEAD:<path>
.
looks like this tool is very buggy. Probably not reliable enough to use, here is some tests:
git annex config --get annex.largefiles
anything
#> anything
# so in theory both git add . and git annex add . should use annex
# but apparently no
# first lets do git annex add
git annex add medicines.jpg
#> add medicines.jpg
#> ok
#> (recording state in git...)
# medicines.jpg -> .git/annex/objects/VP/4F/SHA256E-s11172--839e5e989dd90d32252c1035bfa270613b4d02934c5f2db860851dfa5f13019a.jpg/SHA256E-s11172--839e5e989dd90d32252c1035bfa270613b4d02934c5f2db860851dfa5f13019a.jpg
so looks normal, unlock will use reflink copy, we can verify the BLOCK-RANGE.
git annex unlock medicines.jpg
xfs_bmap -v medicines.jpg
medicines.jpg:
EXT: FILE-OFFSET BLOCK-RANGE AG AG-OFFSET TOTAL
0: [0..23]: 2776..2799 0 (2776..2799) 24 100000
find .git/annex/objects/ -type f -exec xfs_bmap -v {} \;
.git/annex/objects/VP/4F/SHA256E-s11172--839e5e989dd90d32252c1035bfa270613b4d02934c5f2db860851dfa5f13019a.jpg/SHA256E-s11172--839e5e989dd90d32252c1035bfa270613b4d02934c5f2db860851dfa5f13019a.jpg:
EXT: FILE-OFFSET BLOCK-RANGE AG AG-OFFSET TOTAL
0: [0..23]: 2776..2799 0 (2776..2799) 24 100000
git add will not do what is advertised, the stat is regular file not symlink.
git add pts02787667.jpg
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: medicines.jpg
new file: pts02787667.jpg
stat pts02787667.jpg
File: pts02787667.jpg
Size: 173414 Blocks: 344 IO Block: 4096 regular file
Device: 821h/2081d Inode: 148 Links: 1
.git/annex/objects
├── gP
│ └── VF
│ └── SHA256E-s173414--bd553b6abb1ab277e9141257c2b47d5c7278cbe05e7963a11254257cbc7b1949.jpg
│ └── SHA256E-s173414--bd553b6abb1ab277e9141257c2b47d5c7278cbe05e7963a11254257cbc7b1949.jpg
└── VP
└── 4F
└── SHA256E-s11172--839e5e989dd90d32252c1035bfa270613b4d02934c5f2db860851dfa5f13019a.jpg
└── SHA256E-s11172--839e5e989dd90d32252c1035bfa270613b4d02934c5f2db860851dfa5f13019a.jpg
we can verify the file is reflink (CoW):
xfs_bmap -v pts02787667.jpg
pts02787667.jpg:
EXT: FILE-OFFSET BLOCK-RANGE AG AG-OFFSET TOTAL
0: [0..343]: 2800..3143 0 (2800..3143) 344 100000
.git/annex/objects/gP/VF/SHA256E-s173414--bd553b6abb1ab277e9141257c2b47d5c7278cbe05e7963a11254257cbc7b1949.jpg/SHA256E-s173414--bd553b6abb1ab277e9141257c2b47d5c7278cbe05e7963a11254257cbc7b1949.jpg:
EXT: FILE-OFFSET BLOCK-RANGE AG AG-OFFSET TOTAL
0: [0..343]: 2800..3143 0 (2800..3143) 344 100000