我正在尝试将 gitosis 和存储库备份到备份 tarball,然后在空白系统上恢复和测试,以确保在服务器完全故障的情况下,我可以让新系统快速运行。
我有两个目录使用
git clone --mirror gitosis@localhost:gitosis-admin.git gitosis-backup.repo
git clone --mirror gitosis@localhost:test1.git test1-backup.repo
然后去皮
在我安装干净的机器上,我已经提取了 tarball 并完成了
git clone gitosis-backup.repo gitosis-admin
git clone test1-backup.repo test1
进入这两个目录并执行 git log 会显示历史记录。
但这并不适用于新服务器。但是做 git push origin master 不起作用,它声称是最新的。
但是任何从我的新服务器进行克隆的尝试都失败了,因为非常正确,repo 实际上并不是服务器的一部分。
那么我该如何完成工作呢?我一直无法在此站点或任何其他站点上找到有关恢复 gitosis 的答案。
在 VoC 的帮助下测试的输出如下
mkdir git_restore
cd git_restore
mkdir tarballs
cd tarballs
cp ~/backup/*.tgz
tar -zxf gitosis-admin.repo.tgz
tar -zxf test1-backup.repo.tgz
cd ..
mkdir local_repo
cd local_repo
ssh-keygen
sudo apt-get install gitosis
sudo -H -u gitosis gitosis-init < /home/ian/.ssh/id_rsa.pub
ls /srv/gitosis/git # check that this is not a broken sym link
git clone gitosis@localhost:gitosis-admin
cd gitosis-admin
git log # Has the initialise entry
cd ../..
mkdir restore
cd restore
git clone ../tarballs/gitosis-admin.repo gitosis-admin
git clone ../tarballs/test1-backup.repo test1
cd gitosis-admin
git log # Full log is present
git push gitosis@localhost:gitosis-admin master
To gitosis@localhost:gitosis-admin
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'gitosis@localhost:gitosis-admin'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again. See the 'Note about
fast-forwards' section of 'git push --help' for details.
git status
# On branch master
nothing to commit (working directory clean)
git fetch
git merge origin master
Already up-to-date. Yeeah!
git push gitosis@localhost:gitosis-admin master
To gitosis@localhost:gitosis-admin
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'gitosis@localhost:gitosis-admin'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again. See the 'Note about
fast-forwards' section of 'git push --help' for details.
顺便说一句, git push gitosis@localhost:gitosis-admin origin/master 似乎在推动,但是如果我在一个单独的目录中克隆 gitosis-admin 然后执行 git log 那么我只有初始化条目。