Re: way to automatically add untracked files?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sunday 05 August 2007, Shawn O. Pearce wrote:
> Miles Bader <miles@xxxxxxx> wrote:
> > I previously wrote
> > > One thing I often want to do is git-add all untracked files, and also
> > > automatically git-rm all "disappeared" files
> > ...
> > > One way to do this seems to be just "git add ."
> > 
> > Oh, also, "git add ." doesn't seem to do the right thing with
> > "dissapeared" files:  If I do:
> > 
> >     mv foo.cc bar.cc
> >     git add .
> 
> Right.  Who wants "add" to actually mean "add and delete"?
> Shouldn't that be then called "git-add-and-rm"?
> 
> We recently talked about this on the mailing list and decided that
> git-add shouldn't remove files that have disappeared, as doing so
> might break most user's expections of what git-add does.

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

    Add all new files and remove all missing files from the repository.

    New files are ignored if they match any of the patterns in .hgignore. As
    with add, these changes take effect at the next commit.

[...]
---

Adding a git-addremove command should not be much work, and it would be a 
lot friendlier to people whose workflow is more aligned with #2 than #1.


...Johan

-- 
Johan Herland, <johan@xxxxxxxxxxx>
www.herland.net
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux