git 挑选和变基失败



我在主题分支的历史记录中有以下提交:

(此处描述git lola快捷方式)

jochen@autolaptop4:~/projects/infoodle$ git lola
*   0c61616 (refs/stash) WIP on receipt_preview_sprint_to_finish: 3678770 progress
|  
| * 332dc8a index on receipt_preview_sprint_to_finish: 3678770 progress
|/  
* 3678770 (HEAD -> receipt_preview_sprint_to_finish, origin/receipt_preview, receipt_preview, integration) progress
*   ed2ca95 Merge branch 'receipt_preview' of bitbucket.org:richinnz/infoodle-web into receipt_preview
|  
| * 0743777 preview stuff
| * 03a2279 be able to ahndle both rebatable and non-rebatable
| * 1ff3d6c better sample number for preview of receipts
| * 0a0f3ed handle missing {tax receipt} replacement
| * 0ce35c9 remove language files, should not be in git
| * 5cc2b61 identify first key of transaction detail correctly to get data out of transaction record
| * def1132 sort out preview spinner
| * 5622f85 typo when pasting code from master
* | 30ef79c (origin/receipt_search, receipt_search) merge transactiontranslator back into receiptconfigurator
* | 367685c progress transferring sql into configurator
* |   84c71b1 Merge remote-tracking branch 'origin/receipt_search' into receipt_search
|   
| * | 149e5f0 Progress on receipt screen search/ sort/ detail
* | | e927458 processing receiptstodo query into receiptList class, process SQL where parts into ReceiptConfigurator
* | | 80c7c06 list loaded from ajax complete
* | | 99b6ed8 only use global.min when not in debug mode
* | | bf15181 rename
* | | 43fd17a re-indent
* | | 57e38a0 re-indent
* | | c4e7588 save work
| |/  
|/|   
* | 867c918 remove confusing commented out stuff
* | fec8c04 text tweak in phpdoc
|/  
* 75a78ce fix mismatch of function parameter typing after merge

基本上我不小心合并了 origin/receipt_search,我们在完成此功能分支方面改变了计划。

我想从现在开始提交 75a78ce(底部)并申请

0743777 preview stuff
03a2279 be able to ahndle both rebatable and non-rebatable
1ff3d6c better sample number for preview of receipts
0a0f3ed handle missing {tax receipt} replacement
0ce35c9 remove language files, should not be in git
5cc2b61 identify first key of transaction detail correctly to get data out of transaction record
def1132 sort out preview spinner
867c918 remove confusing commented out stuff
fec8c04 text tweak in phpdoc

以相反的顺序转到新分支。

1)我尝试过git樱桃采摘:

git checkout 75a78ce
git checkout -b receipt_preview_sprint_to_finish
git cherry-pick fec8c04..0743777

应用第二次提交时失败:

On branch receipt_preview_sprint_to_finish
You are currently cherry-picking commit 867c918.
(fix conflicts and run "git cherry-pick --continue")
(use "git cherry-pick --abort" to cancel the cherry-pick operation)
Unmerged paths:
(use "git add <file>..." to mark resolution)
both modified:   code/classes/class.receipting.php

我不明白为什么会有冲突。

2)然后我尝试变基:

git branch -f integration 0743777
git rebase --onto receipt_preview_sprint_to_finish fec8c04~1 integration
First, rewinding head to replay your work on top of it...
Fast-forwarded integration to receipt_preview_sprint_to_finish.
jochen@autolaptop4:~/projects/infoodle$ git log
commit 3678770d92b2fd00797d2cda2875c090fc701a1e
Author: Jochen Daum <jd@automatem.co.nz>
Date:   Thu Mar 23 10:48:42 2017 +1300
progress
commit ed2ca95096690c4c419ef491ad65c3c5020120e5
Merge: 30ef79c 0743777
Author: Jochen Daum <jd@automatem.co.nz>
Date:   Thu Mar 23 08:26:23 2017 +1300
Merge branch 'receipt_preview' of bitbucket.org:richinnz/infoodle-web into receipt_preview
# Conflicts:
#   code/ajax/accountcode_functions.php
#   code/ajax/subinclude/person.php
#   code/styles/ennz/admin_donationreceipts.tpl.php
#   code/styles/ennz/header.tpl

但是这两个提交我特别不想要。

我做错了什么?

git cherry-pick的问题很简单:

我现在想从提交 75a78ce(底部)开始并应用 [以fec8c04开头并包含的提交,所以我跑了]

git cherry-pick fec8c04..0743777

Git 中X..Y的符号表示"可从Y访问的所有提交,不包括可从X访问的所有提交"。 这不包括X本身。 这让人想起数学中的半开区间,其中 [3..5] 表示 3、4 和 5,但 (3,5] 仅表示 4 和 5,或 [3, 5) 仅表示 3 和 4。 (这些是用其他方式编写的,例如 ]3, 5] 在某些符号中,并且提交并不是真正的线性方式 - 我们实际上是在做集合减法,而不是间隔 - 但这里的想法是提醒X..Y永远不会包含提交X本身

因此,您需要的是:

git cherry-pick 75a78ce..0743777

或:

git cherry-pick fec8c04^..0743777

以包含提交fec8c04

值得注意的是,这并不完全正确:

git checkout 75a78ce
git branch -b receipt_preview_sprint_to_finish

第二个命令应该是git checkout -b,而不是git branch -b。 但是git branch -b会给你一个错误,所以我想你实际上使用了git checkout -b.:-)

(git rebase方法不会很好地工作,因为它会选择太多的提交来复制到线性序列中。

相关内容

  • 没有找到相关文章

最新更新