git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Am able to delete a file with no trace in the log

From
GPGraham Perks <gperks@ausperks.net>
Date
Jun 2, 2009, 19:33 UTC
Message-ID
<EB2D87B9-3B03-431A-B204-C7799F9BA291@ausperks.net>

We just had this come up. A file was accidentally removed during a merge operation, and we could find no clue in the gitk and git log output as to which change the deletion occurred in. We found the original file addition in a change; but no other mention of this file.

This seems like a bug. The log should show the file being deleted.

This is pretty easy to reproduce. Just run the script below. Here, pretend "c" is the central repo to which two users are pushing/ pulling. The users are using repositories r1 and r2.

# create and init repos md r1 md r2 md c cd c git init --bare cd .. cd r1 && git init && cd .. cd r2 && git init && cd ..

# create a file to conflict later cd r1 echo hello > a.txt git add . git commit -m "add file" git push ../c master

# sync other repo cd ../r2 git pull ../c

# make conflicting change echo helloworld > a.txt git commit -a -m "change file in r2"

# and add a file echo bye > b.txt git add . git commit -m "add file b" git push ../c

# Meanwhile, r1 has been working cd ../r1 echo hellogit > a.txt git commit -a -m "change file in r1" git pull ../c

# edit a.txt to resolve merge vi a.txt

# User in r1 erroneously thinks "ooh, I didn't edit b.txt, I don't want that in my commit!" # This is especially easy to do in git gui. That's what our user did. # Or, the user could legitimately remove the file as part of the merge. Probably # they should git rm, but our user didn't. git reset HEAD b.txt

# But he thinks, "I did merge a.txt" git add a.txt git commit -m "Merged" git push ../c

# Now user in r2 wants to pull r1's changes cd ../r2 git pull ../c

# File b.txt deleted! Woah! How did that happen? # gitk and git log show nothing about the deletion. # There seems to be no evidence about who, how, why, or when the file got deleted. # So it's hard to track down which user mis-used the system and educate them.

Cheers, Graham Perks.

Next: Tony Finch
Message 1 of 26 in “Am able to delete a file with no trace in the log”
  1. Graham PerksJun 2, 2009
  2. Tony FinchJun 2, 2009
  3. Jeff KingJun 2, 2009
  4. Linus TorvaldsJun 2, 2009
  5. Sitaram ChamartyJun 3, 2009
  6. Linus TorvaldsJun 3, 2009
  7. Clean up and simplify rev_compare_tree()Linus Torvalds, Jun 3, 2009
  8. Junio C HamanoJun 3, 2009
  9. Linus TorvaldsJun 3, 2009
  10. Junio C HamanoJun 3, 2009
  11. Linus TorvaldsJun 3, 2009
  12. Linus TorvaldsJun 3, 2009
  13. Avery PennarunJun 3, 2009
  14. Junio C HamanoJun 3, 2009
  15. Linus TorvaldsJun 3, 2009
  16. Junio C HamanoJun 3, 2009
  17. Jeff KingJun 3, 2009
  18. Linus TorvaldsJun 3, 2009
  19. Jeff KingJun 3, 2009
  20. Linus TorvaldsJun 3, 2009
  21. Jeff KingJun 3, 2009
  22. Linus TorvaldsJun 4, 2009
  23. Junio C HamanoJun 4, 2009
  24. Linus TorvaldsJun 3, 2009
  25. Junio C HamanoJun 3, 2009
  26. Junio C HamanoJun 3, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.