git - 将浅回购转换为普通回购
问题描述
我已经“浅化”了一个回购:
FIRST_COMMIT="bf450342272a94117d78eae34a140a2a39359dad"
git rev-parse ${FIRST_COMMIT} > .git/shallow
git fsck --unreachable
git gc --prune=now
现在我尝试推动:
! [remote rejected] develop -> develop (shallow update not allowed)
我知道这个限制是由于回购很浅。
如何将浅回购转换为普通回购?
我不在乎失去旧的历史。其实我想丢掉旧的历史
为了澄清这一点:
- 我希望转换后的存储库保留提交历史记录,以及浅存储库的元数据(日期、作者、提交消息……)
- 我要彻底丢掉旧历史
- 我不关心与原始 repo 的兼容性:这将被视为新 repo
- 我不在乎是否重新创建了提交,只是保留了元数据。
编辑
简单地删除.git/shallow
文件不起作用:
» git push -f --set-upstream myorigin develop
error: Could not read d18d4a247bebd32a3b57b2c0e5f9c28749083211
fatal: revision walk setup failed
error: remote unpack failed: eof before pack header was fully read
error: failed to push some refs to 'git@somehost:repos/somerepo.git'
编辑2
试图通过以下方式来浅显fetch
:
git fetch --unshallow
仍然留下一个grafted
回购:
commit bf450342272a94117d78eae34a140a2a39359dad (grafted)
Author: The author
Date: Thu Nov 29 16:55:05 2018 +0100
Chages by pre-commit hook (!?)
解决方案
以下命令(git 版本 1.8.3)会将浅克隆转换为常规克隆:
git fetch --unshallow
然后,访问原点的所有分支(感谢评论中的@Peter)
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git fetch origin
推荐阅读
- arrays - 检查字符串数组中第一个元素的最后一个字符是否与下一个元素的最后一个字符相同
- python - Python 相当于 R 的 c()?
- django - m2m(多对多)字段上的 django pre_save 验证
- r - 当时间序列数据偏移且不完整时
- excel - 在每次自动更新更改时自动保存 Excel 工作簿
- cumulocity - Cumulocity 工具 - 通过工具将应用程序部署为 zip
- ruby-on-rails - 如何从视图中提取逻辑
- database - 使用数据库包装微服务是一种反模式吗?
- boost - 在 Ubuntu 18.10 上安装 ROS Melodic
- django - 我很难使用 request.POST.get() 获取数据