Pull Request 中提示`commits incorrectly signed off`

场景:

DCO机器人在 Pull Request 中提示commits incorrectly signed off,说明提交历史里有若干 commit 缺少

shell 复制代码
Signed-off-by: Your Name <you@example.com>

DCO

There are 2 commits incorrectly signed off. This means that the author(s) of these commits failed to include a Signed-off-by line in their commit message.

To avoid having PRs blocked in the future, always include Signed-off-by: Author Name authoremail@example.com in every commit message. You can also do this automatically by using the -s flag (i.e., git commit -s).

Here is how to fix the problem so that this code can be merged.

Rebase the branch

If you have a local git environment and meet the criteria below, one option is to rebase the branch and add your Signed-off-by lines in the new commits. Please note that if others have already begun work based upon the commits in this branch, this solution will rewrite history and may cause serious issues for collaborators (described in the git documentation under "The Perils of Rebasing").

You should only do this if:

You are the only author of the commits in this branch

You are absolutely certain nobody else is doing any work based upon this branch

There are no empty commits in the branch (for example, a DCO Remediation Commit which was added using --allow-empty)

To add your Signed-off-by line to every commit in this branch:

Ensure you have a local copy of your branch by checking out the pull request locally via command line.

In your local branch, run: git rebase HEAD~2 --signoff

Force push your changes to overwrite the branch: git push --force-with-lease origin my-branch

解决方案:

shell 复制代码
# 切回工作分支
git branch + 当前工作分支(my-branch)
# 添加上游(原仓库)远端并同步最新主干
git remote add upstream + 远程仓库地址(原始)
git fetch upstream
# 将"想提交"的改动纳入一次带签名的提交
git add ***
git commit -S -m "update proposal"
# 把还在开发、暂时不想进 PR 的改动先藏起来
git stash push -m "WIP: local tweaks" 
# 与主干对齐并在变基过程中为历史提交补签名
git rebase upstream/main
# 把修正后的历史强推回自己的 fork, --force-with-lease仅当远端分支头指针仍在你预期位置时才覆盖,避免误删他人提交
git push --force-with-lease origin 当前工作分支 (origin是fork仓库地址)
# 取回之前 stash 的本地草稿
git stash pop

注意:

git push --force-with-lease origin 若使用 HTTPS 地址推送,GitHub 已禁用帐密登录,需要当前工作分支生成新 PAT

方法:

  1. GitHub ➜ Settings → Developer settings → Personal access tokens → Tokens (classic) → Generate new token
  2. 勾选最少 repo 权限;设定有效期;点击 Generate token 并复制那 40 字符串。
shell 复制代码
git push --force-with-lease origin my-branch
# Username: 你的 GitHub 登录名(如 xxxx)
# Password: 粘贴刚生成的 PAT(终端不显示字符)

注意2

等待 GitHub 自动检测,DCO 成功转绿即可合并。如果仍有缺签提示,说明还有更早的 commit 未补,可继续:

shell 复制代码
git rebase HEAD~3 --signoff
git push --force-with-lease origin my-branch
相关推荐
高频因子挖掘机4 小时前
同一交易日出现重复 K 线:去重前先确认时间、来源和粒度
后端·github·api
SL_staff7 小时前
从邮箱传文档到协同流重构:企业文档协作的系统性破局实践
java·开源·github
用户7273744138849 小时前
版本锁定实战:从 `git tag` 到 `package-lock.json` 的完整闭环
github
暖心hebbie设计学习9 小时前
GitHub 热榜周报(10.19)|5 个把 AI 装回本地的开源项目:多 agent 控制台、本地语音、节点式生成(含技术看点)
人工智能·github
用户别睡觉9 小时前
从 0 到 1 开源:基于 FastAPI 和本地大模型打造一个提示词安全网关
github
mr_g9 小时前
一个注解搞定 AGI,两个注解搞定 AMI —— SmartCall 让 Java 对接 Asterisk 简单到离谱
github
sbjdhjd12 小时前
从签名重放到 Agent Harness:一堂安全课程如何把前端逆向、MCP 与工程约束串起来
网络安全·ai·github·agent·webshell·mcp·harness
逛逛GitHub14 小时前
火了两周的 30 万 Star 逆向 GitHub 开源神器,网友都用它来干啥?
github
wflynn15 小时前
GitHub 日榜趋势速报 | 2026-10-18
开源·github
疯狂敲代码的老刘16 小时前
d2r-mobile:3.2千星开源暗黑破坏神2 iOS兼容层,3天冲上GitHub日榜
ios·github