Files are deleted after commit #132

tonini opened this Issue Jul 10, 2012 · 2 comments


None yet
3 participants

tonini commented Jul 10, 2012


After trying one of the examples all the files are deleted in the repository (marked as ready to be commited):

require 'grit'

count = 1
Dir.chdir("localstore") do
  r ='.')
  i = r.index
  while(count < 10) do
    fname = + count.to_s
    i.add(fname, 'hello ' + fname)
    count += 1
  count = 5
  while(count < 10) do
    puts "HELLO"
    fname = + count.to_s
    i.add('test/' + fname, 'hello ' + fname)
    count += 1
  puts i.commit('my commit')
  puts i.inspect

Git Version => (maybe that's the problem?)

This is a case of advanced git use and a poorly commented example.

No files are created in this test. However the git index is modified. The contents of the files are supplied as strings in i.add(fname, 'hello ' + fname). The index is committed, but since files weren't created in the first place they become 'deleted' because they are not in the repo.

If you run git checkout master in the repo after running the example, you will see what you expected.


bkeepers commented Feb 3, 2014

Grit is no longer maintained. See #183 and check out libgit2/rugged.

@bkeepers bkeepers closed this Feb 3, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment