如何将提交 ID 添加到一系列 cherry picks 中?
How to add a commit ID to a series of cherry picks?
我正在努力为 LineageOS gerrit 做贡献。
所以基本上我从上游内核分支中挑选了一系列提交...
只有现在,none 的精心挑选的提交才具有 Change-ID。
我知道我可以使用提交挂钩手动添加一个并且:
git commit --amend
但是,有 834 次左右的提交...
我也知道我可以 运行 一个交互式的 rebase 通过以下方式稍微减轻我的痛苦:
git rebase -i $FIRST_CP
# Change every commit from pick to edit
git commit --amend
git rebase --continue
然而,这几乎与重新挑选每一次提交一样糟糕。
注意:我没有对Gerrit服务器的管理员访问权限,所以我暂时无法删除更改ID的要求。
我束手无策,这真的阻碍了我的贡献...
希望有人有更好的主意。
Addenum:我也尝试合并分支并希望它会被接受...虽然没有骰子。
-n, --no-commit
将允许您在没有任何提交的情况下挑选一个或多个现有提交。完成此操作后,您可以使用一个提交 ID 提交所有精心挑选的内容。
尝试git filter-branch --msg-filter
。
假设我们有在 ~/commit-msg
生成 Change-Id 的钩子,现在我们在 master
。
#create an orphan branch "tmp" from "master".
git checkout --orphan tmp master
git commit -m 'new root'
#cherry-pick all the commits from an upstream kernel branch.
git cherry-pick <all-the-commits>
#rewrite the commit message of every commit on "tmp"
git filter-branch --msg-filter 'git log -1 --pretty=%B $GIT_COMMIT > msg.txt;~/commit-msg msg.txt;cat msg.txt'
#all the commits now have Change-Id
#cherry-pick all of them except the root to "master"
root=$(git log --pretty=%H --max-parents=0)
git checkout master
git cherry-pick $root..tmp
msg.txt
是在当前版本库下的.git-rewrite/
中创建的,命令完成后.git-rewrite/
会自动删除。所以让我们忽略它。
msg-filter命令模拟生成Change-Id的过程。我认为它可以更优雅,但在我的测试中有效。
我正在努力为 LineageOS gerrit 做贡献。
所以基本上我从上游内核分支中挑选了一系列提交...
只有现在,none 的精心挑选的提交才具有 Change-ID。 我知道我可以使用提交挂钩手动添加一个并且:
git commit --amend
但是,有 834 次左右的提交... 我也知道我可以 运行 一个交互式的 rebase 通过以下方式稍微减轻我的痛苦:
git rebase -i $FIRST_CP
# Change every commit from pick to edit
git commit --amend
git rebase --continue
然而,这几乎与重新挑选每一次提交一样糟糕。
注意:我没有对Gerrit服务器的管理员访问权限,所以我暂时无法删除更改ID的要求。
我束手无策,这真的阻碍了我的贡献... 希望有人有更好的主意。
Addenum:我也尝试合并分支并希望它会被接受...虽然没有骰子。
-n, --no-commit
将允许您在没有任何提交的情况下挑选一个或多个现有提交。完成此操作后,您可以使用一个提交 ID 提交所有精心挑选的内容。
尝试git filter-branch --msg-filter
。
假设我们有在 ~/commit-msg
生成 Change-Id 的钩子,现在我们在 master
。
#create an orphan branch "tmp" from "master".
git checkout --orphan tmp master
git commit -m 'new root'
#cherry-pick all the commits from an upstream kernel branch.
git cherry-pick <all-the-commits>
#rewrite the commit message of every commit on "tmp"
git filter-branch --msg-filter 'git log -1 --pretty=%B $GIT_COMMIT > msg.txt;~/commit-msg msg.txt;cat msg.txt'
#all the commits now have Change-Id
#cherry-pick all of them except the root to "master"
root=$(git log --pretty=%H --max-parents=0)
git checkout master
git cherry-pick $root..tmp
msg.txt
是在当前版本库下的.git-rewrite/
中创建的,命令完成后.git-rewrite/
会自动删除。所以让我们忽略它。
msg-filter命令模拟生成Change-Id的过程。我认为它可以更优雅,但在我的测试中有效。