Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • I'm on git version 2.7.4 but still I'm getting this error message Relative path can only be used from the toplevel of the working tree . I'm doing git submodule add ../../../functest Commented Dec 16, 2016 at 6:46
  • 2
    @user3426358 yes, that is expected: the answer above os about the capability of doing a git submoduel add from any subfolder of the main repo, not just from its root folder. It is not about referencing the submodule remote repo with a relative path. If you do, you will get the error message that you see. Commented Dec 16, 2016 at 7:05
  • 1
    @user3426358 And by the way, that error message (that you see: "Relative path can only be used from the toplevel of the working tree") is not the one from the original question ("You need to run this command from the toplevel of the working tree") Commented Dec 16, 2016 at 7:06
  • So what is the way around my situation? How do we reference the submodule remote repo with a relative path? Commented Dec 16, 2016 at 7:08
  • @user3426358 The error message comes from github.com/github/git-msysgit/blob/master/…, which check that your path starts with $wt_prefix (the working tree prefix): here, as I mention in my previous answer (stackoverflow.com/a/1974381/6309), it is the location relative to the superproject's origin repository. See this comment: stackoverflow.com/questions/1974181/…. But an absolute path would be easier. Commented Dec 16, 2016 at 7:18