I was wondering how to sign(-s
) off previous commits that I have made in the past in git?
问题:
回答1:
To signoff the previous commit, use amend option:
git commit --amend --signoff
回答2:
Try this one to redo old commits with a -S
:
git filter-branch -f --commit-filter 'git commit-tree -S "$@"' HEAD
After that, you have to git push -f
. But be careful, the commit ids will change and other people will become out of sync.
回答3:
Considering sign-offs modify the commit message , uses git filter-branch
to achieve that.
git filter-branch --msg-filter \
"cat - && echo && echo 'Signed-off-by: Dan McGee <email@example.com>'" \
HEAD
(example from "git filter-branch
magic")
Or, following Curt J. Sampson's suggestion, using 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
caveat: this will change the SHA1 of your existing commits, and you might have to force push the result, which can be problematic if your commits are already shared by others.
回答4:
For me just ammending signof, didn't actually verify my commits on github.
The solution that is worked for me is going back, and then sign each commit with -S
git commit --amend -S
Also if you check if your commit is actually signed, and your email/name is simply not appended, use this command
git show HEAD --show-signature
Extra tip: If you are already amending your commits, you may want your real name in them (see using git log
). You may be using your github handle name, which is not needed. Only correct email is needed and in field of username you should use your full name and github will track it correctly with your github handle name. So to correct your user name and sign last commit use:
git commit --amend --author="FULL NAME <email>" -S
and also set full name for user name in future by
git config --global user.name "FULL NAME"
回答5:
I had a similar issue. Here, thanks to Robin Johnson from Gentoo Linux is a trick to add the signature to all my previous unpushed commits:
$ 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
$