Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Files are deleted after commit #132

tonini opened this Issue · 2 comments

3 participants



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.


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

@bkeepers bkeepers closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.