如何克隆一个 Git 仓库命名空间

3

我想创建一个命名空间并将其推送到一个裸库,以下是我的操作步骤:推送工作正常,但克隆和拉取不成功。

GIT_NAMESPACE=work

我创建了一个空的代码库并添加了一些提交记录

完成了向裸库的推送;在裸库中,我确实看到了命名空间/work

现在

如果我克隆它,命名空间就不存在了。

我已经设置了相同的环境变量。

2个回答

3

我对git的命名空间不熟悉,决定尝试一下。以下是结果。它涉及三个存储库。 sample 存储库将推送到 sample-remote 裸存储库的工作命名空间。而且,我正在将 sample-remote 的工作命名空间克隆到 sample-clone 存储库中。

#!/bin/bash

set -e

cd ~/Code
git init sample
cd sample
touch file
git add file
git commit -m "First commit"
git remote add origin ~/Code/sample-remote.git
git init --bare ~/Code/sample-remote.git
GIT_NAMESPACE=work git push origin master
cd ..
git clone ext::'git --namespace=work %s ~/Code/sample-remote.git' \
    sample-clone -b master
cd sample-clone
touch file2
git add file2
git commit -m "Second commit"
git push

没有 -b master 参数,我得到了以下错误:

warning: remote HEAD refers to nonexistent ref, unable to checkout.

工作目录为空。


0
这取决于您想要访问存储库的方式。
请参见gitnamespaces(7)
文件系统访问示例:
git clone ext::'git --namespace=foo %s /path/to/repo.git'

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接