1

我有以下基于 git 的结构:

  • 本地存储库 #1,大部分开发工作都在此完成
  • 远程存储库#1,我推送所有提交的地方,我们称之为“开发存储库”
  • 远程存储库#2,我只想存储一些提交,完全独立于本地(以及开发)存储库历史,我们称之为“生产存储库”

我的问题是,我怎样才能轻松地使它工作,有以下假设:

  • 生产仓库应仅包含选定的提交(我使用一些特殊命令提交)
  • development repo 是一个“普通”的远程存储库,我在其中推送整个历史记录
  • 本地存储库包含所有历史提交,因此不允许压缩其提交

我知道,这不是一个“好概念”,我可以通过其他存储库的设计来获得类似的结果,但我的问题不是关于这个想法,而是使用现有工具实现这个结果的可能性。

我目前使用以下 bash 脚本来执行此操作。当我想提交“生产仓库”时,只需运行脚本,然后像往常一样使用开发仓库。

#!/bin/bash

# $1 - local repository directory
# $2 - local repository name
# $3 - production (remote) repository
# $4 - init or push
# $5 - message

tmpmaindir="/tmp"
tmpdir="gitresync"

# creating temp env
cd $tmpmaindir
mkdir $tmpdir
cd $tmpdir
if [ $4 = "init" ]; then #creating prod repo
    cp -r $1 .
        cd $2
        rm -rf .git
    git init
    git add '*'
    git commit -m "$5"
    git remote add origin $3
    git push -u origin master
else # pushing to existing prod repo
    git clone $3
    rsync -av --exclude='.git' $1 .
    cd $2
    git add '*'
    git commit -m "$5"
    git push $3
fi
# cleaning
cd $tmpmaindir
rm -rf $tmpdir 2> /dev/null

是否可以使用纯 git 工具来实现?或者至少不创建临时文件和本地存储库?

4

1 回答 1

0
git tag alz-v4.6 $(git commit-tree -m'foo' someref^{tree})
git push dropbox-repo alz-v4.6
于 2013-08-12T13:29:14.863 回答