给定2个git存储库(产品A和产品B),带子模块(CommonSubmodule,SomeOtherSubmodule)
D:\Repositories\ProductA\
D:\Repositories\ProductA\CommonSubmodule
D:\Repositories\ProductA\SomeOtherSubmodule
D:\Repositories\ProductA\SomeOtherSubmodule\
D:\Repositories\ProductB\SomeOtherSubmodule\
D:\Repositories\ProductB\CommonSubmodule\
我在网上发现了一个允许通过post_checkout挂钩记录分支的脚本
#!/bin/sh
previous_head_ref=$1
new_head_ref=$2
is_branch_checkout=$3
if [[ "$previous_head_ref" != "$new_head_ref" ]] && [[ "$is_branch_checkout" == 1 ]]; then
branch=$(git rev-parse --abbrev-ref HEAD)
#if [[ "develop" != "$branch" ]]; then
path="$(dirname "$0")/.."
logfile="$path/x_branch_log"
ts=$(date +%s)
echo "$branch|1|$ts" >> $logfile
echo "Logging $branch|1|$ts to $logfile"
echo PWD is $PWD
#fi
fi
在post_checkout上下文中,无论安装挂钩的子模块有多深,如何在不编码绝对路径的情况下,如何获取根目录(D:\ Repositories)?
D:\Repositories\
此外,我如何获得根产品目录,例如
D:\Repositories\ProductA\
D:\Repositories\ProductB\
答案 0 :(得分:-1)