0

Previously I would squash all my commits in a branch by doing the following:-

git rebase -i f41790727e8c136d9987d5099cd01429459d8065

However, if I enable GPG signing on the repository.

Git Config Entry

[commit]
    gpgsign = true

Then I get the following error.

gpg: cannot open tty `no tty': No such file or directory
error: gpg failed to sign the data
fatal: failed to write commit object
Could not apply f608db8... Testing

I have tried the suggestion in How to retain commit gpg-signature after interactive rebase squashing? but

git rebase -i --gpg-sign=<my-email> f41790727e8c136d9987d5099cd01429459d8065

fails with the same error.

I am really stuck on how I can resolve this. You must be able to rebase with GPG signing.

baynezy
  • 6,493
  • 10
  • 48
  • 73
  • Your GPG wants to talk, interactively, to *you*, but `git rebase` runs it in a manner in which it has no access *to* you. I don't use GPG much and am not sure what options might help here but clearly the `--gpg-sign` argument is intended to provide something that GPG would otherwise ask you for. Perhaps you can figure out what it is that GPG needs from you here and how you can set things up so that GPG can get it without interacting with you. – torek May 30 '19 at 20:54
  • See also https://unix.stackexchange.com/questions/60213/gpg-asks-for-password-even-with-passphrase – torek May 30 '19 at 20:59
  • 1
    I think you need to install and configure `gpg-agent` + a non-tty (GUI) `pinentry` program. – phd May 31 '19 at 09:32
  • Try `export GPG_TTY=$(tty)` from terminal – onuriltan May 01 '20 at 13:50

1 Answers1

0

May be relevant for someone drifting from search engines. I got the following error for a strange reason.

gpg: cannot open tty `no tty': No such file or directory
error: gpg failed to sign the data
fatal: failed to write commit object
Could not apply 94e5xxxx... xxxxxx

I had set a sequence of squash, drop that failed while trying to rebase and I got this error. Check git status and you may find failed changes on the stage. For me, the issue was not related to gpg but it was related to failed git rebase --continue; the error misled me.

Tirtha R
  • 1,148
  • 1
  • 14
  • 24