小智 25
尝试使用以下方法重做旧提交-S:
git filter-branch -f --commit-filter 'git commit-tree -S "$@"' HEAD
Run Code Online (Sandbox Code Playgroud)
在那之后,你必须git push -f.但要小心,提交ID将会改变,其他人将变得不同步.
Kes*_*ran 23
如果有人仍在寻找一种更好的自动化方式来签署提交。
尝试这个:
git rebase --exec 'git commit --amend --no-edit -n -S' -i commit-hash
Run Code Online (Sandbox Code Playgroud)
这将重新设置所有内容,直到提交哈希(X 提交)
然后git push -f需要将历史更改推回远程
ssc*_*rth 17
这些天(从Git 2.13开始)你通常可以做类似的事情
git rebase --signoff HEAD~2
Run Code Online (Sandbox Code Playgroud)
将Signed-off-by页脚添加到最后 2 次提交(在本例中)。
Von*_*onC 10
考虑签名修改提交消息,用于git filter-branch实现该目的.
git filter-branch --msg-filter \
"cat - && echo && echo 'Signed-off-by: Dan McGee <email@example.com>'" \
HEAD
Run Code Online (Sandbox Code Playgroud)
(来自" git filter-branch魔术 "的例子)
或者,按照Curt J. Sampson的建议,使用git interpret-trailers:
git config trailer.sign.key "Signed-off-by"
git filter-branch --msg-filter \
"cat - && echo && git interpret-trailers --trailer 'sign: 'Signed-off-by: Dan McGee <email@example.com>'" \
HEAD
Run Code Online (Sandbox Code Playgroud)
警告:这将更改现有提交的SHA1,您可能必须强制推送结果,如果您的提交已经被其他人共享,则可能会出现问题.
对我来说只是修改signof,实际上没有验证我在github上的提交.
为我工作的解决方案是返回,然后签署每个提交 -S
git commit --amend -S
Run Code Online (Sandbox Code Playgroud)
此外,如果您检查您的提交是否实际已签名,并且您的电子邮件/名称未被追加,请使用此命令
git show HEAD --show-signature
Run Code Online (Sandbox Code Playgroud)
额外提示: 如果您已经在修改提交,可能需要在其中使用您的真实姓名(请参阅使用git log).您可能正在使用您的github句柄名称,这是不需要的.只需要正确的电子邮件,在用户名字段中,您应该使用您的全名,github将使用您的github句柄名称正确跟踪它.因此,要更正您的用户名并签署上次提交使用:
git commit --amend --author="FULL NAME <email>" -S
Run Code Online (Sandbox Code Playgroud)
并在以后设置用户名的全名
git config --global user.name "FULL NAME"
Run Code Online (Sandbox Code Playgroud)
An interactive rebase with the -S flag will do the job.
Let's say you need to sign off the last n commits (make sure to checkout the latest of those n commits).
Run:
$ git rebase -S -i HEAD~n
# The `-S` flag is important.
# It tells Git to sign the following commits.
Run Code Online (Sandbox Code Playgroud)
This gives a list of the last n commits.
Now, change pick to edit prefix for all the commits you want to sign.
Once done, close the editor. A new editor will open with everything about the commit.
由于提交中不需要更改任何内容,因此请保存文件并退出编辑器。您还可以更改提交消息。
对其他提交重复此操作。
要推送最新的历史记录,git push remote branch -f.
有一个问题 - 它可以重写您的提交。
如果您签署一个 4 个月前的提交,它可能会覆盖其日期并使其看起来像是今天创建的。所以,当你想保留你的提交历史时不推荐。
小智 5
我有一个类似的问题。在这里,感谢来自Gentoo Linux的Robin Johnson,这是一个将签名添加到我之前未执行的所有提交中的技巧:
$ git pull && git rebase --gpg-sign --force-rebase origin/master && git push --signed
Already up-to-date.
Current branch master is up to date, rebase forced.
First, rewinding head to replay your work on top of it...
Applying: sci-biology/KING: new package
Applying: dev-lang/yaggo: version bump, fix install procedure
Applying: sci-libs/htslib: version bump
Applying: sci-biology/bcftools: version bump
Applying: sci-biology/samtools: version bump
Applying: sci-biology/libBigWig: new release with io.h renamed to bigWigIO.h
Applying: sci-biology/MaSuRCA: add more URLs to HOMEPAGE
Applying: sci-biology/SPAdes: update comments on bundled dev-libs/boost
Applying: sci-biology/khmer: added a comment how to proceed with src_compile()
Applying: sci-biology/picard: version bump
Applying: sci-biology/ruffus: pint EGIT_REPO_URI to the archive URL of code.google.com
Applying: sci-biology/vcftools: the 0.1.15_pre release was just renamed to 0.1.15 by upstream
Applying: sci-biology/nanopolish: new package
Applying: sci-biology/libBigWig: version bump
Counting objects: 75, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (75/75), done.
Writing objects: 100% (75/75), 14.51 KiB | 0 bytes/s, done.
Total 75 (delta 55), reused 0 (delta 0)
remote: To github.com:gentoo/sci.git
remote: 29c5e3f5d..b37457700 master -> master
To git+ssh://git.gentoo.org/proj/sci.git
29c5e3f5d..b37457700 master -> master
$
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
24833 次 |
| 最近记录: |