如何备份StGit工作区?

eva*_*low 2 git

我经常通过将git repo嵌套在Subversion,Perforce或CVS沙箱中来使用git'guerrilla-style'。当我以这种方式工作时,我想在USB记忆棒上创建一个“远程”存储库,以便在硬盘死机的情况下进行备份:

$ git --bare init /f/projects/myproj.git
$ git remote add origin /f/projects/myproj.git
$ git push -u origin master
Run Code Online (Sandbox Code Playgroud)

然后,我只需要记住不时键入git push即可备份我的工作。如果我的回购被收回,我可以通过以下方式将其收回:

$ git clone /f/projects/myproj.git
Run Code Online (Sandbox Code Playgroud)

最近,我一直在使用StGit针对上游Perforce存储库维护一堆补丁程序。我的简单备份策略在这种情况下不再起作用。都不起作用git clonestg clone似乎不起作用:如果我stg series在克隆后键入,它会告诉我stg series: master: branch not initialized

翻看一下,我已经看到stgit创建了一个master.git分支和其他几个临时(??)分支来存储元数据。似乎应该可以进行设置,以便将所有这些分支都推送到备份存储库中,但是我不确定该如何处理。

更新 [2011年12月15日]:查看我要在qgit中备份的由stgit管理的存储库,我看到它看起来像这样:

在此处输入图片说明

我尝试了Jefromi的建议push --all

$ git --bare init /f/projects/myproj.git
$ git remote add origin /f/projects/myproj.git
$ git push -u origin master
Run Code Online (Sandbox Code Playgroud)

这会推送master.stgit分支,但不会推送其他一些必需的元数据:

在此处输入图片说明

从上面的屏幕快照中,您可以看到原始存储库中有一个顶级patches文件夹和一个refs/patches文件夹,但备份中没有。所有这些使我相信我在树错树皮。有没有办法使用标准git命令备份StGit元数据?如果不是这样,在变基失败或硬盘驱动器出现故障的情况下,在复杂补丁系列中备份正在进行的工作的最佳方法是什么?

eva*_*low 5

似乎尝试通过克隆备份StGit工作区会适得其反。我已经确定了一种更简单的方法,该方法依赖于stg exportstg import。它是这样的:

$ pwd
/c/d/projects/luasand_stg
$ stg push -a
$ stg series
+ add-copyright-notice
+ add-bn-namespace
> fix-tabs
$ stg export --dir=/f/projects/luasand_stg_patches
Checking for changes in the working directory ... done
$ cd ..
# Pretend STG sandbox got borked
$ rm -rf luasand_stg
# Re-clone it from the original repo
$ stg clone luasand luasand_stg
Cloning into luasand_stg...
done.
$ cd luasand_stg
# No patches?  No problem, just reimport them from the backup
$ stg series
$ stg import -s /f/projects/luasand_stg_patches/series
Checking for changes in the working directory ... done
Importing patch "add-copyright-notice" ... done
Importing patch "add-bn-namespace" ... done
Importing patch "fix-tabs" ... done
Now at patch "fix-tabs"
# Everything restored
$ stg series
+ add-copyright-notice
+ add-bn-namespace
> fix-tabs
Run Code Online (Sandbox Code Playgroud)

因此,我只是尝试将每个单独的补丁备份到/f/projects/luasand_stg_patches我的USB记忆棒上,而不是尝试备份整个存储库。这意味着我必须确保将源存储库luasand也备份到某个地方,以便可以通过(重新)克隆stg clone并重新导入补丁来重新创建工作区的状态。

我不喜欢这个工作流程,但至少我能理解。我会等一会儿再接受这个答案,看看是否有人可以提供更简单的解决方案...