更新时间:2022-11-03 10:00:11
你可以读取 .git/HEAD
的内容,然后读取你从中得到的文件的内容.
you can read the contents of .git/HEAD
, then read the contents of the file that you get from that.
>
您将遇到的警告是,您从上述步骤中获得的 SHA-1 可能位于一个包文件中(git 将多个更改压缩在一起以节省空间的方式).我建议使用 git 而不是尝试自己操作 .git 文件夹内容.
The caveat that you will run into is that the SHA-1 that you get from the above steps may be in a pack file (the way git compresses multiple changes together to save space). I would recommend using git instead of trying to manipulate the .git folder contents yourself.