【发布时间】:2014-02-20 04:52:02
【问题描述】:
与此问题相关的存储库位于here。
我使用
从 master 分支创建了一个名为 apt-offline-python3-dev 的新分支
GitHub 网页界面。
我想要做的是从提交774-784 接管来自主分支的提交,因此使它们属于apt-offline-python3-dev 分支,而不是属于master 分支。
因为,例如,当您查看 latest 提交时,它清楚地表示 master 而不是 apt-offline-python3-dev,这是合乎逻辑的,因为我发送所有这些提交到主分支, 在重构存储库之前。
然后我想将 master 分支重置回其原始状态,这意味着返回提交 9f2f667d13,如 2013 年 6 月 16 日的 this 页面所示。
现在,我知道git cherry-pick 和git merge,但根本不知道这是否可能。
更新:
+1 为马特的回答引导我朝着正确的方向前进。不幸的是,问题仍然存在。
当我按照 Matt 建议的顺序发出命令时,会发生以下情况:
git checkout apt-offline-python3-dev
Branch apt-offline-python3-dev set up to track remote branch apt-offline-python3-dev from origin.
Switched to a new branch 'apt-offline-python3-dev'
git cherry-pick 9f2f667d134330c0de8700258ab98cae0ac89438
error: could not apply 9f2f667... half implementation of lock, please verify
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
因为这里已经失败,所以不需要调用git revert命令。
现在,如果颠倒顺序,将git revert 替换为git reset --hard,它确实有效:
git reset --hard 9f2f667d134330c0de8700258ab98cae0ac89438
HEAD is now at 9f2f667 half implementation of lock, please verify
git cherry-pick ba8662eb8e01cebc969126650baa22776a27430d
[apt-offline-python3-dev 78c9aa5] Another initial test commit
Author: codingaround <codingaround@outlook.com>
24 files changed, 1438 insertions(+), 1328 deletions(-)
create mode 100644 IMPORTANT_README.md
rewrite apt_offline_core/AptOfflineMagicLib.py (85%)
git log 透露,哈希是一个新的:
git log
commit 78c9aa5b732d559f141c9bf77c801c1644710432
Author: codingaround <codingaround@outlook.com>
Date: Mon Sep 30 20:11:55 2013 +0200
Another initial test commit
现在剩下的问题是:我如何保留提交哈希值还是不可能?
【问题讨论】:
标签: git github branch git-commit