git - 尽早重新排序分支上的提交而不发生冲突

Cod*_*ien 5 git conflict rebase

我将如何在没有任何冲突的情况下尽早将提交移至分支上(无需太多手动工作,例如 rebase -i)?

例如

ABCDX

应该成为

ABXCD

如果将 X 与 C 和 D 交换没有冲突,但将 X 与 B 交换会导致冲突。

谢谢。

Cod*_*ien 0

嗯,这几乎有效,但需要一些清理。

使用它一段时间后,我遇到了另一个问题,我已将其发布在这里

#!/bin/sh -e

# todo: 与 git 集成
GIT_DIR=./.git/

提交ID=$1

如果[“$1”=“”]; 然后
   echo 用法: $0 commitid
   1号出口
菲

tmpdir="$GIT_DIR/气泡工作"
/bin/rm -rf "$tmpdir"
mkdir“$tmpdir”

# 签出带有分离头的提交
git checkout -q $commitid^0 || 死亡“无法分离头部”

而[1=1];做

# todo 管道输出以避免临时文件
# 查看 git-rebase.sh

patchfile=`git format-patch -k --full-index --src-prefix=a/ --dst-prefix=b/ --no-renames -o "$tmpdir" HEAD~1`
回显补丁= $补丁文件

git checkout -q HEAD~2
git am --rebasing "$patchfile" || 死了“git 失败了”
/bin/rm -f "$补丁文件"

回声循环
完毕



/bin/rm -rf "$tmpdir"