相关疑难解决方法(0)

组合多个git存储库

假设我的设置看起来很像

phd/code/
phd/figures/
phd/thesis/
Run Code Online (Sandbox Code Playgroud)

由于历史原因,这些都有自己的git存储库.但我想将它们合并为一个,以简化一些事情.例如,现在我可能会进行两组更改,并且必须执行类似的操作

cd phd/code
git commit 
cd ../figures
git commit
Run Code Online (Sandbox Code Playgroud)

表演(现在)很棒

cd phd
git commit
Run Code Online (Sandbox Code Playgroud)

似乎有几种方法可以使用子模块或从我的子存储库中提取,但这比我正在寻找的要复杂一些.至少,我很高兴

cd phd
git init
git add [[everything that's already in my other repositories]]
Run Code Online (Sandbox Code Playgroud)

但这似乎不是一个单行.有什么git可以帮助我吗?

git

203
推荐指数
8
解决办法
7万
查看次数

git filter repo 可以从许多按日期交织提交的存储库中创建单一存储库吗?

使用git-filter-repo是否可以将 N 个存储库组合成一个单一存储库,重写提交,以便提交交织在一起,或者按日期“压缩”?目前,我仅使用 2 个存储库对此进行测试,每个存储库都有自己的子目录。操作后,每个存储库的提交都位于彼此的“顶部”,而不是交织在一起。我真正想要的是能够通过创作数据拥有完全线性的历史记录,而无需添加合并提交。

历史


rm -rf ___x
mkdir ___x
cd ___x

echo "creating the monorepo"
git init
touch "README.md"
git add .
git commit -am "Hello World!"

declare -A data
data=( 
    ["foo"]="https://github.com/bcanzanella/foo.git"
    ["bar"]="https://github.com/bcanzanella/bar.git"
)

for d in "${!data[@]}"; 
do  {
    REPO_NAME=$d
    REPO_REMOTE=${data[$d]}

    # since we can use a foo/bar as the repo identifier, replace the / with a -
    REPO_DIR_TMP="$(mktemp -d -t "${REPO_NAME/\//-}.XXXX")"

    echo "REPO REMOTE: $REPO_REMOTE"
    echo "REPO NAME: $REPO_NAME"
    echo "REPO TMP DIR: $REPO_DIR_TMP"
    echo …
Run Code Online (Sandbox Code Playgroud)

git bash github git-filter-repo

6
推荐指数
1
解决办法
744
查看次数

标签 统计

git ×2

bash ×1

git-filter-repo ×1

github ×1