选择提交并保留原始SHA代码 [英] cherry-pick a commit and keep original SHA code

查看:98
本文介绍了选择提交并保留原始SHA代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在获取的远程服务器上选择一个提交,同时保留其原始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:


  1. 所指的;基本上是提交所在分支中存储库的当前内容。

  2. 父提交的SHA。
  3. b $ b
  4. 提交消息

  5. 作者信息:姓名,电子邮件和时间戳。

  6. 提交者信息:姓名,电子邮件和时间戳。

  1. The tree it refers to; basically, the current content of the repository in the branch in which the commit appears.
  2. The SHA of the parent commit(s).
  3. The commit message.
  4. The author information: name, email and timestamp.
  5. 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代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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