在存储库目录外使用 git 远程命令

using git remote command outside the repository dir

有没有什么方法可以将存储库的位置传递给命令 git remote,以便命令将它作为一个主题来处理?

我要打电话

git remote add origin <url>

在存储库目录之外,是否可以将存储库位置作为参数传递给命令?

git remote documentation - 你有什么方法可以做到这一点吗?

https://git-scm.com/docs/git#git--Cltpathgt

git -C <path>

运行 就好像 git 是在而不是当前工作目录中启动的。

https://git-scm.com/docs/git#git---git-dirltpathgt

git --git-dir=<path>

设置存储库的路径。这也可以通过设置 GIT_DIR 环境变量来控制。它可以是当前工作目录的绝对路径或相对路径。