cd进入Git仓库内的特定目录

问题描述 投票:0回答:1

我有多个基于相同远程仓库的项目树。我想cd进入其中任何一个的特定目录,但基于此时PWD的位置。

例:

如果我有3个克隆

clone1
clone2
clone3

当在clone2 / test /我希望能够做CDGOTO并将自动转到某些目录时

clone2/test/test1/test2/foo

所以shell命令会评估我当前的git repo然后cd到该repo中寻找有趣的目录。

如果我在克隆1中,那么CDGOTO将会:

clone1/test/test1/test2/foo
git shell fish
1个回答
4
投票
alias CDGOTO='cd $(git rev-parse --show-toplevel)/test/test1/test2/foo'
© www.soinside.com 2019 - 2024. All rights reserved.