1

When trying to add all of the files I deleted without using

git rm 

I found the command

git add -u

Imagine my consternation when it did not work as advertised.

Instead, I got the following warning.

warning: The behavior of 'git add --update (or -u)' with no path argument from a
subdirectory of the tree will change in Git 2.0 and should not be used anymore.
To add content for the whole tree, run:

  git add --update :/
  (or git add -u :/)

To restrict the command to the current directory, run:

  git add --update .
  (or git add -u .)

Where can I find documentation on the change from git add -u to git add --update :/ ?

And no, apparently the :/ is not a frowney-face. It is an actual command.

Community
  • 1
  • 1
Tara Roys
  • 1,756
  • 2
  • 17
  • 31
  • The actual behavior has not changed yet, it's just warning you to get used to typing either of those two versions to specify which one you mean. The current meaning with no arguments is the same as "add -u ." so if you get used to typing that instead of "add -u" you will see no change. If you *meant* to get the equivalent of `cd root_of_git_work_tree; git add -u .; cd back_where_I_was`, use the colon-slash version. – torek Feb 12 '14 at 03:04

1 Answers1

0

Where can I find documentation on the change from git add -u to git add --update :/ ?

In commit 0fa2eb53, introduced in git v1.8.2 (March 2013) by Matthieu Moy (moy):

Most Git commands that can be used with or without pathspec operate tree-wide by default, the pathspec being used to restrict their scope.
A few exceptions are: 'git grep', 'git clean', 'git add -u' and 'git add -A'.
When run in a subdirectory without pathspec, they operate only on paths in the current directory.

The inconsistency of 'git add -u' and 'git add -A' is particularly problematic since other 'git add' subcommands (namely 'git add -p' and 'git add -e') are tree-wide by default.
It also means that "git add -u && git commit" will record a state that is different from what is recorded with "git commit -a".

Flipping the default now is unacceptable, so let's start training users to type 'git add -u|-A :/' or 'git add -u|-A .' explicitly, to prepare for the next steps:

  • forbid 'git add -u|-A' without pathspec (like 'git add' without option)

  • much later, maybe, re-allow 'git add -u|-A' without pathspec, that will add all tracked and modified files, or all files, tree-wide.

A nice side effect of this patch is that it makes the :/ magic pathspec easier to discover for users.

When the command is called from the root of the tree, there is no ambiguity and no need to change the behavior, hence no need to warn.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250