gpt4 book ai didi

git - 如何获取当前目录相对于git仓库根目录的路径?

转载 作者:太空狗 更新时间:2023-10-29 12:49:29 26 4
gpt4 key购买 nike

我看过 this question ,它告诉如何获取特定文件相对于 git repo 根目录的路径。但是我现在想获取当前目录的路径,而不是具体的文件。如果我使用

git ls-tree --full-name --name-only HEAD .

我得到目录中所有文件的列表。

这可能吗?

最佳答案

怎么样:

$ git rev-parse --show-prefix

来自 man git-rev-parse:

--show-prefix
When the command is invoked from a subdirectory, show
the path of the current directory relative to the top-level
directory.

关于git - 如何获取当前目录相对于git仓库根目录的路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39922706/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com