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

git ls-files -o under .git/ prints all repository files

From
Yasushi SHOJI <yashi@atmark-techno.com>
Date
Jan 19, 2007, 01:04 UTC
Message-ID
<87r6trsu7n.wl@mail2.atmark-techno.com>
Hi all,

ls-files -o prints all files under .git if you are in the .git directory. this is pretty dangerous since we now have git clean to delete files marked others.

sure in UNIX env., you can easily shoot yourself in the foot. but it'd might be nice to help newbies.

I'm not sure how we should fix this.  should we
1) prevent to run any git command under .git unless .git is also
   managed by git (ie. .git/.git or something exists)
2) prevent ls-files -o to print any files under .git/ even if we are
   in the directory.
the way to reproduce is:
$ git init
Initialized empty Git repository in .git/
$ echo hello > hello.c
$ git add .
$ git commit -m initial
Created initial commit b40c824b521f6c60434043f0cce08a88b4031ed8
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 hello.c
$ cd .git
$ git ls-files -o
HEAD
config
description
hooks/applypatch-msg
hooks/commit-msg
hooks/post-commit
hooks/post-update
hooks/pre-applypatch
hooks/pre-commit
hooks/pre-rebase
hooks/update
index
info/exclude
logs/refs/heads/master
objects/b4/0c824b521f6c60434043f0cce08a88b4031ed8
objects/bc/2d2dcb34e8313627d45ad6ef38beddf560501d
objects/ce/013625030ba8dba906f756967f9e9ca394464a
refs/heads/master
$ git clean
Removing HEAD
Not removing branches/
Removing config
Removing description
Not removing hooks/
Removing index
Not removing info/
Not removing logs/
Not removing objects/
Not removing refs/
Not removing remotes/
$ cd ..
$ git ls-files
fatal: Not a git repository
$ 
-- 
          yashi
Next: Junio C Hamano
Message 1 of 26 in “git ls-files -o under .git/ prints all repository files”
  1. Yasushi SHOJIJan 19, 2007
  2. Junio C HamanoJan 19, 2007
  3. Andy ParkinsJan 19, 2007
  4. Junio C HamanoJan 19, 2007
  5. Andy ParkinsJan 19, 2007
  6. Yasushi SHOJIJan 19, 2007
  7. Simon 'corecode' SchubertJan 19, 2007
  8. Alex RiesenJan 19, 2007
  9. Simon 'corecode' SchubertJan 19, 2007
  10. Alex RiesenJan 19, 2007
  11. Simon 'corecode' SchubertJan 19, 2007
  12. Alex RiesenJan 19, 2007
  13. Simon 'corecode' SchubertJan 19, 2007
  14. Alex RiesenJan 19, 2007
  15. Simon 'corecode' SchubertJan 19, 2007
  16. Andreas EricssonJan 19, 2007
  17. Matthias KestenholzJan 19, 2007
  18. Johannes SchindelinJan 19, 2007
  19. Junio C HamanoJan 19, 2007
  20. Yasushi SHOJIJan 23, 2007
  21. Commands requiring a work tree must not run in GIT_DIRJohannes Schindelin, Jan 23, 2007
  22. Junio C HamanoJan 24, 2007
  23. Johannes SchindelinJan 24, 2007
  24. Junio C HamanoJan 24, 2007
  25. Alex RiesenJan 19, 2007
  26. Alex RiesenJan 19, 2007

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.