2014-01-28 42 views
3

與此問題相關的存儲庫位於hereGitHub:將主提交應用到另一個分支

我從主分支創建了一個名爲apt-offline-python3-dev的新分支,其中的
GitHub Web界面。

我想要做的是接管主分支提交從提交774 - 784,因此讓他們屬於,而不是屬於master分支的分支apt-offline-python3-dev,。

因爲,當你看latest提交例如重組之前,上面清清楚楚地寫着的代替的apt-離線python3-dev的,因爲我發送的所有這些提交到主分支,它是合乎邏輯的, 存儲庫。

話,我想主分支復位到原來的狀態,這意味着回犯9f2f667d13截至6月16日在this頁面看到,2013年

現在,我知道git cherry-pickgit merge,但不要真的不知道這是否可能。

更新:
+1馬特的回答帶領我在正確的方向。不幸的是,仍然存在問題。
這裏發生了什麼,當我在馬特暗示順序發出命令:

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 revertgit 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 <[email protected]> 
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 <[email protected]> 
Date: Mon Sep 30 20:11:55 2013 +0200 

    Another initial test commit 

的疑問,現在仍然是:我如何保持提交哈希或不可能?

回答

2

使用git cherry-pick從主到所需的分支應用更改:

git checkout apt-offline-python3-dev 
git cherry-pick <sha1> 
git cherry-pick <sha1> 
... 

然後,在一個單獨的步驟中,還原的變化掌握:

git checkout master 
git revert <sha1> 
git revert <sha1> 
... 

(GIT復歸將增加新的承諾撤消所做的更改)

相關問題