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

Re: way to automatically add untracked files?

From
Johan Herland <johan@herland.net>
Date
Aug 6, 2007, 07:30 UTC
Message-ID
<200708060930.13967.johan@herland.net>
In-Reply-To
<f95q7l$8lv$2@sea.gmane.org>
On Monday 06 August 2007, Jakub Narebski wrote:
Show 27 quoted lines
> Johan Herland wrote:
> 
> > So different users seem to have two different (almost incompatible) 
> > expectations to git-add:
> > 
> > 1. git-add adds new files into the index. git-add has _no_ business removing 
> > deleted files from the index.
> > 
> > 2. git-add updates the index according to the state of the working tree. 
> > This includes adding new files and removing deleted files.
> > 
> > 
> > Both interpretations are useful and worth supporting, but git-add currently 
> > seems focused on #1 (and rightly so, IMHO).
> > 
> > Even though #2 can be achieved by using a couple of git-add commmands (or a 
> > longer series of more obscure plumbing-level commands), it might be worth 
> > considering the more user-friendly alternative of adding a dedicated 
> > command for supporting #2. Such a command already exists in a similar RCS:
> > 
> > ---
> > $ hg addremove --help
> > hg addremove [OPTION]... [FILE]...
> > 
> > add all new files, delete all missing files
> 
> git update-index --add --remove?

This is actually the nicest looking command I've seen so far in this thread. It's reasonably simple to deduce what it does, or rather, should do...

Of course it has some shortcomings:
- It only works on individual files. Supplying a directory (subdir or '.')
  is not supported.
- It _seems_ to not support .gitignore, i.e. new files that are already in
  .gitignore give the same feedback (add 'foo') as new files that are not
  ignored. But when you commit, the ignored files will in fact _not_ be
  committed (which is correct, AFAICS). It would be nice if git-update-index
  told me that up front.

Of course, It may be that git-update-index is too low-level (i.e. plumbing) to support the above use case in a user-friendly fashion. In that case, feel free to ignore the above issues.

Have fun!
...Johan
-- 
Johan Herland, <johan@herland.net>
www.herland.net
Previous: Jakub NarebskiNext: Junio C Hamano
Message 31 of 40 in “way to automatically add untracked files?”
  1. Miles BaderAug 5, 2007
  2. Shawn O. PearceAug 5, 2007
  3. Junio C HamanoAug 5, 2007
  4. Miles BaderAug 5, 2007
  5. Shawn O. PearceAug 5, 2007
  6. Miles BaderAug 5, 2007
  7. Junio C HamanoAug 5, 2007
  8. Miles BaderAug 5, 2007
  9. Junio C HamanoAug 5, 2007
  10. Miles BaderAug 5, 2007
  11. Junio C HamanoAug 5, 2007
  12. Miles BaderAug 5, 2007
  13. Johannes SchindelinAug 5, 2007
  14. Miles BaderAug 5, 2007
  15. Steffen ProhaskaAug 5, 2007
  16. Johan HerlandAug 5, 2007
  17. David KastrupAug 5, 2007
  18. Theodore TsoAug 5, 2007
  19. Johan HerlandAug 5, 2007
  20. Miles BaderAug 6, 2007
  21. Johannes SchindelinAug 6, 2007
  22. Miles BaderAug 6, 2007
  23. Johannes SchindelinAug 6, 2007
  24. Miles BaderAug 6, 2007
  25. Johan HerlandAug 6, 2007
  26. Johannes SchindelinAug 6, 2007
  27. Steffen ProhaskaAug 5, 2007
  28. Johannes SchindelinAug 6, 2007
  29. Steffen ProhaskaAug 6, 2007
  30. Jakub NarebskiAug 6, 2007
  31. Johan HerlandAug 6, 2007
  32. Junio C HamanoAug 6, 2007
  33. David KastrupAug 6, 2007
  34. Miles BaderAug 7, 2007
  35. Linus TorvaldsAug 5, 2007
  36. Junio C HamanoAug 5, 2007
  37. David KastrupAug 5, 2007
  38. Benchmarking git-add vs git-ls-files+update-index (was: way to automatically add untracked files?)David Kastrup, Aug 5, 2007
  39. Miles BaderAug 5, 2007
  40. Linus TorvaldsAug 5, 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.