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

Re: Using gpg and gitattributes together

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Feb 29, 2008, 14:59 UTC
Message-ID
<alpine.LSU.1.00.0802291455120.22527@racer.site>
In-Reply-To
<alpine.LSU.1.00.0802270008550.22527@racer.site>
Hi,
On Wed, 27 Feb 2008, Johannes Schindelin wrote:
Show 19 quoted lines
> I just added my .netrc to a repository where I track some files that I 
> would hate to lose.  However, since I mirror that repository to a 
> machine where other people than me have root access, I thought that I 
> encrypt the file with gpg.
> 
> To make this procedure more convenient for me, I decided not to encrypt 
> with a private key, but with a passphrase, and to use gitattributes to 
> do the encryption for me:
> 
> $ echo 'netrc filter=gpg' > .gitattributes
> $ git config filter.gpg.clean 'gpg --cipher-algo AES256 -c'
> $ git config filter.gpg.smudge 'gpg --decrypt'
> $ git add netrc
> 
> It asks quite a few times for the passphrase (as expected), but I had to 
> add the file twice (not expected).  However, since it worked now, I am 
> happy.
> 
> Maybe somebody else will find this information useful.

Unfortunately, this procedure has an issue I was not able to fix, and not even Daniel's checkout patch could fix it.

When encrypting, gpg uses a random element (to make the encryption harder to break, I guess). So when I update netrc with "git add" (and nothing was changed), git will have a _different_ blob.

So I just tried "git checkout netrc", hoping that the index would be updated to say that the netrc file is current, after writing it.

But that did not work, since git checkout insisted on readding the file (which again resulted in a different blob, and therefore netrc seems to be out-of-date at all times).

So scrap that method.

Ciao, Dscho

Previous: Johannes SchindelinNext: Jeff King
Message 2 of 3 in “Using gpg and gitattributes together”
  1. Johannes SchindelinFeb 27, 2008
  2. Johannes SchindelinFeb 29, 2008
  3. Jeff KingFeb 29, 2008

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.