git 当前分支变基失败

git rebase over current branch fails

我有一个正在使用 git 管理的项目。

我希望每个提交都能干净地应用到以前的历史记录中,因为提交补丁是由 git 本身生成的。

如果我有

------tagA--commit_A1--commit_A2--commit_A3
    \
     \[branch A]
      \
       \-commit_A'1--commit_A'2--commit_A'3--commit_A'4

我在分支 A,它源于 tagA

证实了这一点
git merge-base A tagA

哪个 returns tagA 提交了 sha。我试着发出

git rebase tagA

变基行为应该是:

程序应该让我回到 branch_A 的提示,没有任何更改。

相反,我在其中一个提交中遇到了冲突。

例子

# git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git GIT_linux
# cd GIT_linux
# git remote add linux-at91 https://github.com/linux4sam/linux-at91.git
# git fetch linux-at91
# git checkout -b linux-3.10-at91 linux-at91/linux-3.10-at91
# git rebase v3.10
First, rewinding head to replay your work on top of it...
Applying: dmaengine: at_hdmac/trivial: correct typo in comment
Applying: dmaengine: at_hdmac: extend hardware handshaking interface identification
Applying: dmaengine: at_hdmac/trivial: rearrange CFG register bits assignment
Applying: DMA: AT91: Get transfer width
Applying: DMA: AT91: Get residual bytes in dma buffer
Applying: dma: use platform_{get,set}_drvdata()
Applying: dma: mxs-dma: Staticize mxs_dma_xlate
Applying: dma: at_hdmac: remove unnecessary platform_set_drvdata()
Applying: dma: timb_dma: remove unnecessary platform_set_drvdata()
Applying: dw_dmac: remove inline marking of EXPORT_SYMBOL functions
Applying: dma: tegra20-apbdma: err message correction
Applying: dma: tegra: avoid channel lock up after free
Applying: dmaengine: sirf: set dma residue based on the current dma transfer position
Applying: dma: of: Remove restriction that #dma-cells can't be 0
Applying: dma: of: Remove check on always true condition
Applying: dma: of: Remove restriction that #dma-cells can't be 0
Using index info to reconstruct a base tree...
M   drivers/dma/of-dma.c
Falling back to patching base and 3-way merge...
Auto-merging drivers/dma/of-dma.c
CONFLICT (content): Merge conflict in drivers/dma/of-dma.c
Failed to merge in the changes.

发生这种情况有原因吗?我的存储库是否以某种方式损坏了?

变基不起作用,合并可以...

我试过相反的方法,我可以做到这一点

git checkout -b my3.10.84 v3.10.84
git merge linux-at91/linux-3.10-at91

这导致了几个冲突的文件,我修复并提交了这些文件。

此失败似乎表明您尝试变基的提交范围包含合并。我测试了您的上述序列,但除了将 -p 选项添加到 git rebase 之外(以保留合并提交而不是跳过它们):

# git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git GIT_linux
# cd GIT_linux
# git remote add linux-at91 https://github.com/linux4sam/linux-at91.git
# git fetch linux-at91
# git checkout -b linux-3.10-at91 linux-at91/linux-3.10-at91
# git rebase -p v3.10

这样好像避免了冲突。我认为正在发生的事情是,尝试在不包括来自源分支的合并的情况下进行变基未能包括这些合并解决的任何合并冲突,因此您将不得不重新解决已在任何分支中解决的每个冲突来自源分支的合并。在 rebase 中包含合并允许 git 以与最初解决冲突相同的方式解决这些冲突。