如何用git更改特定提交的SHA-1? [英] How to change the SHA-1 of a specific commit in place with git?

查看:216
本文介绍了如何用git更改特定提交的SHA-1?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标提交可能有父母和子代。



它需要替换原来的



所以它不像 cherry 命令那么简单。



我的问题会等待对于精确解决方案。

解决方案

不,你不能那样做。



SHA-1的目的是防止像这样的变化。整个git体系结构取决于SHA-1在所有git存储库中唯一标识对象的假设。没有办法解决这个问题(不是没有重新设计一切,就是这样)。



详细信息在 Git Magic book

The target commit may have parents and descendants.

it needs to replace the old commit in place,

so it's not as simple as cherry command.

My question will wait for an exact solution.

解决方案

No, you can't do that.

The point of SHA-1 is to prevent changes like these. The whole git architecture depends on the assumption that SHA-1 uniquely identify the object in all git repository. No way to workaround this (not without redesigning everything, that is).

The details are explained in the Git Magic book.

这篇关于如何用git更改特定提交的SHA-1?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆