5 ms·
It always annoys me when git does this: $ git submodule update You need to run this command from the toplevel of the working tree. I bet git knows exa
by hesselink 14y ago
It always annoys me when git does this:
$ git submodule update
You need to run this command from the toplevel of the working tree.
I bet git knows exactly where that is. So go there and do it!
- eridius 14y agoIt may know exactly where that is, but it doesn't necessarily know that you weren't trying to only update submodules in the current directory. Most git commands operate only on stuff reachable from the current directory, but `git submodule update` is incapable of being limited like that.
- chacha102 14y agoI'm not sure that is true... You can update only a specific repo if you'd like. In which case it would be possible to limit the submodule command to only submodules existing in the current directory. Yes, it would need to scale back up to the .gitmodules file, but it is still possible.
- eridius 14y agoYes, obviously the behavior of `git submodule update` could be rewritten. But the way it works right now, it can't be restricted to just submodules reachable from the current directory.
- raylu 14y agoThis might be because it's ambiguous which submodules you want to update if you have nested submodules. In other words, git knows "exactly where that is" by searching parent directories until it sees a ".git". Unfortunately, submodules also have ".git" in them since they're full git repositories themselves. git submodules are not the nicest part of git, unfortunately.
- hesselink 14y agoOK, so it wouldn't work if you're in a submodule. It could print a warning if there are no submodules. But if would still work perfectly fine in the majority of the cases. For those also annoyed, I use this git alias, which does what I want: sup = !sh -c 'cd `git rev-parse --show-toplevel` && git submodule update --init' -
- pseut 14y agoHonestly, git's the only program on this page that I'm fine with it being explicit and pedantic about what it's going to do. There are many situations where it could probably guess what I wanted to do but be wrong... I mean, christ, I fetch and merge as separate steps.