search

Home  >  Q&A  >  body text

git - grit怎么修改代码,并且提交代码

我想用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")

代码运行下来,是可以修改代码,但是却将这个仓库里面其他文件都删除了。。。

求高手该怎么写才对?

怪我咯怪我咯2807 days ago677

reply all(1)I'll reply

  • 迷茫

    迷茫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-infogit 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...

    reply
    0
  • Cancelreply