我正在尝试使用 Grit 写入 Git 存储库。我可以轻松地创建一个 repo 并提交:
repo = Repo.init_bare("grit.git")
index = Index.new(repo)
index.add('myfile.txt', 'This is the content')
index.commit('first commit')
我还可以轻松地进行第二次提交,使用第一次提交作为父提交:
index.add('myotherfile.txt', 'This is some other content')
index.commit("second commit", [repo.commits.first])
但是现在我如何在不遍历整个提交历史的情况下获取这两个文件的内容呢?我没有更聪明的方法来获取回购中文件的当前状态吗?