gpt4 book ai didi

windows - Windows Docker git : cd: . git 错误:不是目录

转载 作者:行者123 更新时间:2023-12-05 05:48:07 29 4
gpt4 key购买 nike

我有一台带有 mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019 Docker 镜像的 Windows 10 主机,

git 是通过

安装的
RUN powershell.exe -ExecutionPolicy RemoteSigned `
iex (new-object net.webclient).downloadstring('https://get.scoop.sh'); `
scoop install python git

我的 git 仓库有子模块。当我在本地 checkout repo 并尝试通过

构建它时
docker run --rm -it -v %cd%:C:\Temp -w C:\Temp buildtools2019 cmd.exe /C build.bat

当 git 尝试更新子模块时出现以下错误(我使用 CMake 作为构建系统):​​

-- Submodule update
/mingw64/libexec/git-core/git-sh-setup: line 365: cd: .git: Not a directory
Unable to determine absolute path of git directory
CMake Error at CMakeLists.txt:47 (message):
git submodule update --init failed with 1, please checkout submodules

但是当我刚启动容器,在容器里面做git clone然后执行我的批处理脚本的时候,git没有问题。克隆的 repo 和映射的 repo 有什么区别?

编辑:映射的文件夹列表:

PS C:\TEMP> dir


Directory: C:\TEMP


Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 1/27/2022 6:59 AM .git
d----- 1/26/2022 6:01 PM src
-a---- 1/26/2022 6:01 PM 88 .gitmodules
-a---- 1/26/2022 6:01 PM 162 build.bat

这是出现问题的例程:

# Make sure we are in a valid repository of a vintage we understand,
# if we require to be in a git repository.
git_dir_init () {
GIT_DIR=$(git rev-parse --git-dir) || exit
if [ -z "$SUBDIRECTORY_OK" ]
then
test -z "$(git rev-parse --show-cdup)" || {
exit=$?
gettextln "You need to run this command from the toplevel of the working tree." >&2
exit $exit
}
fi
test -n "$GIT_DIR" && GIT_DIR=$(cd "$GIT_DIR" && pwd) || {
gettextln "Unable to determine absolute path of git directory" >&2
exit 1
}
: "${GIT_OBJECT_DIRECTORY="$(git rev-parse --git-path objects)"}"
}

当我还在 shell 中时,我可以切换到任何目录,但是从这个脚本内部,我只能切换到挂载点之外的文件夹,即 c:\TEMP

最佳答案

我打开了一个ticket在 git-for-windows 项目页面上。问题可以缩小到 msys2,但调试仍未完成。

目前,有一个解决方法:使用 git 2.11.0。

ADD https://github.com/git-for-windows/git/releases/download/v2.11.0.windows.1/Git-2.11.0-64-bit.exe git.exe
RUN c:\git.exe /SP- /VERYSILENT /NORESTART /NOCANCEL /CLOSEAPPLICATIONS /RESTARTAPPLICATIONS -Wait -NoNewWindow; `
Remove-Item -Force git.exe

关于windows - Windows Docker git : cd: . git 错误:不是目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70867805/

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