简体   繁体   中英

How to detect correct GIT_DIR and GIT_WORK_TREE of the parent Git repository in a submodule

I'd like to implement a submodule in GNU Bash to check all GNU Bash scripts in the parent repository, excluding all submodules' Bash scripts.

I've already know that git ls-files -z \\*.bash will do the job properly, the problem is I don't know how to detect the exact GIT_DIR and GIT_WORK_TREE environment variables of the parent repository to export. How to achieve it?

I found a way to solve this issue, simply change the working directory to the parent directory of the current GIT_WORK_TREE(which we should now be in the parent repository's worktree), then call git worktree list --porcelain | grep worktree | cut -f 2- -d ' ' git worktree list --porcelain | grep worktree | cut -f 2- -d ' ' git worktree list --porcelain | grep worktree | cut -f 2- -d ' ' to fetch the parent repository's worktree.

This might not be a good method though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM