问题描述
我想在获取的远程服务器上选择一个提交,同时保留其原始SHA提交代码(我的当前分支基于此远程服务器,我将其重置为先前的状态)。
I would like to cherry-pick a commit on a fetched remote while keeping it's original SHA commit code (my current branch is based on this remote which I resetted to a previous state).
推荐答案
根据不同的信息计算git SHA哈希:
A git SHA hash is computed from different pieces of information:
- 所指的树;基本上是提交所在分支中存储库的当前内容。
- 父提交的SHA。 b $ b
- 提交消息。
- 作者信息:姓名,电子邮件和时间戳。
- 提交者信息:姓名,电子邮件和时间戳。
- The tree it refers to; basically, the current content of the repository in the branch in which the commit appears.
- The SHA of the parent commit(s).
- The commit message.
- The author information: name, email and timestamp.
- The committer information: name, email and timestamp.
即使您进行编辑精心挑选的提交,以便树,提交消息,作者和提交者信息完全相同,父提交(或多个提交,如果处理合并提交)的SHA将始终不同。因此,您将无法在选择樱桃后生成相同的SHA哈希(除非找到SHA冲突;))。
Even if you edit a cherry-picked commit so that the tree, the commit message, the author and committer information are exactly the same, the SHA of the parent commit (or commits, if dealing with merge commits) will be always different. So, you will not be able to generate the same SHA hash after a cherry-pick (unless you find a SHA collision ;) ).
这篇关于选择提交并保留原始SHA代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!