3

I've always been puzzled by this:

$ git submodule
You need to run this command from the toplevel of the working tree.

Why do I need to run it from the top level directory? Is it a technical reason, or just because of a convention / possible flaw ?

aspyct
  • 3,625
  • 7
  • 36
  • 61

1 Answers1

2

Note: since git 1.8.4 (August 2013), and commit 091a6eb, you don't have to be at top-level to run git submodule update.
This is because git rev-parse has a new --prefix option.

--prefix <arg>

Behave as if git rev-parse was invoked from the <arg> subdirectory of the working tree.
Any relative filenames are resolved as if they are prefixed by <arg> and will be printed in that form.

That same limitation is gone for git submodule add as well.

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