git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Question about git filter-branch with signed commits

From
ALAdam Liter <adam.liter@gmail.com>
Date
Jul 25, 2015, 20:17 UTC
Message-ID
<5085A037-0E20-4FA4-B553-E54345F4FAA5@gmail.com>
Hello,

I'm trying to clean up the commit history of a git repository by removing certain files. The repository contains signed commits, and when I try to use git filter-branch, the PGP signature is converted to the first line of the commit message.

Is this the expected behavior? If so, is there something that I can do to prevent this from happening?

I'm using git v. 2.4.6. I tried reducing the behavior to a simple case. I asked about this on Stack Overflow (http://stackoverflow.com/q/31552774/2571049), but the question hasn't really gotten any uptake, so I thought I would try asking here too.

In trying to reproduce the behavior in a minimal way, I did the following:

mkdir pgp-git-test cd pgp-git-test git init touch a.txt git add a.txt git commit -m "Add a.txt" -S touch b.txt git add b.txt git commit -m "Add b.txt" -S git filter-branch --index-filter 'git rm --cached --ignore-unmatch a.txt' --prune-empty HEAD git log --oneline --decorate b4efdf0 (HEAD -> master) iQIcBAABCgAGBQJVrvqHAAoJ [...] -----END PGP SIGNATURE----- 9f82e63 iQIcBAABCgAGBQJVrvp7AAoJ [...] -----END PGP SIGNATURE-----

As can be seen after running git log --oneline --decorate, the PGP signature has become the first line of the commit. The rest of the commit message is still there, but it's on a line below the PGP signature.

How can I prevent this from happening when using git filter-branch?

Also, one thing that I was a bit surprised about when trying to create this minimal example is that the first commit is still there. Does anyone know why the commit history still contains the first commit, since the first commit only involved the file a.txt and since I passed --prune-empty to git filter-branch? Shouldn't this commit have been eliminated from the log?

Thanks in advance for the help! I'm relatively new to git, so apologies for bugging you all if this is a trivial error on my part. Thanks!

Best, Adam Liter

Next: Jacob Keller
Message 1 of 3 in “Question about git filter-branch with signed commits”
  1. Adam LiterJul 25, 2015
  2. Jacob KellerJul 25, 2015
  3. Adam LiterJul 26, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.