blob # 类型:blob mark :1 # 序号:1 data 11 # 文件(大小):11 bytes "11111111"# 文件内容 # 换行 LF (必须单行) reset refs/heads/main # 表示当前分支(ref)为main commit refs/heads/main # 类型:commit mark :2 # 序号:2 author Li Linchao <lilinchao@oschina.cn> 1633749662 +0800 # author committer Li Linchao <lilinchao@oschina.cn> 1633749662 +0800 # commiter data 16 # 数据(大小):16 第一个commit # commit message(header, body) M 100644 :1 README.md # filechang: M(modify), D(delete), :1表示该commit修改了序号1中的文件 # 换行 blob mark :3 data 33 CopyRight@2021 Author: lilinchao
commit refs/heads/main mark :4 author Li Linchao <lilinchao@oschina.cn> 1633749750 +0800 committer Li Linchao <lilinchao@oschina.cn> 1633749750 +0800 data 21 add new LICENSE file from :2 # 表示该commit的parent是序号为2的commit M 100644 :3 LICENSE # 表示对序号3中的文件LICENSE进行了修改
blob mark :5 data 22 "11111111" "22222222"
commit refs/heads/main mark :6 author Li Linchao <lilinchao@oschina.cn> 1633749780 +0800 committer Li Linchao <lilinchao@oschina.cn> 1633749780 +0800 data 21 修改 README 文件 from :4 M 100644 :5 README.md
reset refs/remotes/origin/main # 表示远程分支为main from :6 # 表示远程分支的commit对应本地序号6的commit
blob mark :1 data 33 CopyRight@2021 Author: lilinchao
reset refs/heads/main commit refs/heads/main mark :2 author Li Linchao <lilinchao@oschina.cn> 1633749750 +0800 committer Li Linchao <lilinchao@oschina.cn> 1633749750 +0800 data 21 add new LICENSE file M 100644 :1 LICENSE
只有要 dump 到输入流中时的 mark ID 才是实际顺序的 ID,所以可以在实际 dump 时才 NewID(),否则始终记录的是原始顺序 ID。
需要使用 git -c core.quotepath配置处理文件名:
1 2 3 4 5 6 7 8 9 10 11 12
# git -c core.quotepath true M 100644 :1 "Name and a\nLF" M 100644 :1 "Name and an\tHT" M 100644 :1 "Name\"" M 100644 :1 Name M 100644 :1 "With SP in it" M 100644 :1 "\346\277\261\351\207\216\t\347\264\224" M 100644 :1 "\346\277\261\351\207\216\n\347\264\224" M 100644 :1 "\346\277\261\351\207\216 \347\264\224" M 100644 :1 "\346\277\261\351\207\216\"\347\264\224" M 100644 :1 "\346\277\261\351\207\216/file" M 100644 :1 "\346\277\261\351\207\216\347\264\224"
1 2 3 4 5 6 7 8 9 10 11 12
# git -c core.quotepath false M 100644 :1 "Name and a\nLF" M 100644 :1 "Name and an\tHT" M 100644 :1 "Name\"" M 100644 :1 Name M 100644 :1 "With SP in it" M 100644 :1 "濱野\t純" M 100644 :1 "濱野\n純" M 100644 :1 "濱野 純" M 100644 :1 "濱野\"純" M 100644 :1 濱野/file M 100644 :1 濱野純
reset refs/heads/main commit refs/heads/main mark :2 author A U Thor <author@example.com> 1112912773 -0700 committer C O Mitter <committer@example.com> 1112912773 -0700 data 9 addition M 100644 :1 "path with\nnewline" M 100644 :1 "path with \"quote\"" M 100644 :1 "path with \\backslash" M 100644 :1 "path with space"
commit refs/heads/main mark :3 author A U Thor <author@example.com> 1112912773 -0700 committer C O Mitter <committer@example.com> 1112912773 -0700 data 7 rename from :2 R "path with\nnewline""subdir/path with\nnewline" R "path with \"quote\"""subdir/path with \"quote\"" R "path with \\backslash""subdir/path with \\backslash" R "path with space""subdir/path with space"
commit refs/heads/main mark :4 author A U Thor <author@example.com> 1112912773 -0700 committer C O Mitter <committer@example.com> 1112912773 -0700 data 9 deletion from :3 D "subdir/path with\nnewline" D "subdir/path with \"quote\"" D "subdir/path with \\backslash" D "subdir/path with space"