2012-08-21 5 views
36

git 명령 줄을 사용하여 GitHub에서 서명 된 태그를 만들려고합니다. (샘플) 사용자 이름이 Full Name (skytreader) <[email protected]> 인 GPG 키를 생성했습니다. 이 작업을 마치면 signed tag을 만들려고합니다. 그러나 다음과 같은 오류가 발생합니다 :git 태그 지정을위한 GPG 키 생성

gpg: skipped "full <[email protected]>": secret key not available 
gpg: signing failed: secret key not available 
error: gpg failed to sign the data 
error: unable to sign the tag 

나는 표시된 사용자 이름으로 다른 키를 만들어야한다는 것을 알았습니다. 그런데 "full"이라는 이름을 입력하면 gpg은 내 이름이 5 자 이상이어야한다고 불평합니다.

어떻게이 키를 git에 사용합니까?

GPG로 내 태그에 서명 할 때 git 사용자 이름을 변경하여 실제 이름을 5 자 이상으로 변경합니까?

답변

14

커미터 이름은 ~/.gitconfig 파일에 있습니다. 해당 항목을 실제 이름으로 변경하십시오 (어쨌든 커밋을 원하는 방식입니다). 좋아하는 편집기에서 파일을 편집하거나 다음을 발행 할 수 있습니다.

git config --global user.name "<name>" 
+0

하나 더. gitconfig에 "(skytreader)"부분을 포함시킬 수 있습니까? 그래서 다른 GPG 키를 생성 할 필요가 없습니까? – skytreader

+6

원하는대로 할 수 있습니다. 사실,'-u' 또는'--local-user' 플래그를 사용하여 특정 ''을 지정할 수 있습니다 ('git config --global user.signingkey '으로 전역 적으로 설정할 수도 있습니다.) – Christopher

35

먼저 ID에 gpg 키가 있는지 확인해야합니다.

$ gpg --list-key 

이 같은 표시해야하는 경우 : 더 GPG 키가없는 경우

  1. pub 2048R/6AB3587A 2013-05-23
  2. uid xxx (gpg for xxx)
  3. sub 2048R/64CB327A 2013-05-23

합니다. 당신은 키가 이미 생성 된 경우

gpg (GnuPG) 2.0.14; Copyright (C) 2009 Free Software Foundation, Inc. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

Please select what kind of key you want:

  1. (1) RSA and RSA (default)
  2. (2) DSA and Elgamal
  3. (3) DSA (sign only)
  4. (4) RSA (sign only)

Your selection? RSA keys may be between 1024 and 4096 bits long. What keysize do you want? (2048)
Requested keysize is 2048 bits
Please specify how long the key should be valid.

  0 = key does not expire 
     <n> = key expires in n days 
     <n>w = key expires in n weeks 
     <n>m = key expires in n months 
     <n>y = key expires in n years 

Key is valid for? (0)
Key does not expire at all
Is this correct? (y/N) y

GnuPG needs to construct a user ID to identify your key. 

Real name: xxx 
Email address: [email protected] 
Comment: gpg for xxx 

You selected this USER-ID: 
    "xxx(gpg for xxx) <[email protected]>" 

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O 
You need a Passphrase to protect your secret key. 

can't connect to `/xxx/.gnupg/S.gpg-agent': No such file or directory 
We need to generate a lot of random bytes. It is a good idea to perform 
some other action (type on the keyboard, move the mouse, utilize the 
disks) during the prime generation; this gives the random number 
generator a better chance to gain enough entropy. 
+0

내 gitconfig에서 일치하지 않았기 때문에이 글을 쓰려면 공란으로 남겨주세요. –

8

것은, 당신이 (당신의 자식 사용자 ID 사이의 일치에 대한 걱정없이 특정 키를 사용하여 자식을 알 수 있습니다 : 당신은 당신이 출력이

$ gpg --gen-key 

다음을 작성해야합니다 이름 + 이메일) 및 GPG 키의 ID. 그래도 gy user.email이 서명 된 태그의 GPG 키에있는 이메일 중 하나와 일치하거나 다른 사용자에게 유용하기 위해 커밋해야합니다.

: 당신은 당신이에있어 오직 현재 저장소에 대한 user.signingkey을 설정할 수 있습니다

git config --global user.signingkey 6AB3587A 

또는 :

컴퓨터의 글로벌 사용에 대한 키를 설정하려면, 당신의 자식 글로벌 설정을 설정

git config user.signingkey 6AB3587A 
+0

공용 컴퓨터/서버에 있다면'git config --local user.signingkey 6AB3587A'를 선호합니다. – dotslash