我想用https://github.com/mojombo/grit
实现修改git仓库代码。
r = Grit::Repo.new('/projects/atest.git').index
r.add('lib/test.rb', "aaaa")
r.commit("update test", [r.commits.first], Grit::Actor.new("test", "test@email.com"), nil, "master")
代码运行下来,是可以修改代码,但是却将这个仓库里面其他文件都删除了。。。
求高手该怎么写才对?
迷茫2017-04-24 09:12:26
If you use the command line, use the git ls-tree -r 'master^{tree}'
的内容(上次提交的文件列表)和修改部分(写在后边)一同传递给 git update-index --add --index-info
(git add
operation). That is, the index contains unmodified and modified files (all files to be put into the new version).
So, maybe you should add the unmodified files to the index as well?
PS: grit depends on git...