2012-08-21 15 views
36

के लिए एक जीपीजी कुंजी उत्पन्न करना मैं गिटहब में गिट कमांड लाइन का उपयोग कर हस्ताक्षरित टैग बनाने की कोशिश कर रहा हूं। मैंने एक (नमूना) उपयोगकर्ता नाम Full Name (skytreader) <[email protected]> के साथ एक जीपीजी कुंजी उत्पन्न की। ऐसा करने के बाद, मैं signed tag बनाने का प्रयास करता हूं। हालांकि मुझे निम्न त्रुटि मिलती है:गिट टैगिंग

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 

मुझे लगता है कि मुझे संकेतित उपयोगकर्ता नाम के साथ एक और कुंजी बनाने की आवश्यकता है। लेकिन फिर, "पूर्ण" नाम दर्ज करना, gpg शिकायत करता है कि मेरा नाम कम से कम 5 वर्ण लंबा होना चाहिए।

मैं इस कुंजी का उपयोग गिट के साथ कैसे करूं?

क्या मैं जीपीजी के साथ अपने टैग पर हस्ताक्षर करने के लिए उपयोगकर्ता नाम गिट उपयोग बदलता हूं ताकि मुझे कम से कम 5 वर्ण लंबा नाम मिल सके?

उत्तर

14

कमिटर नाम आपके ~/.gitconfig फ़ाइल में स्थित है। उस प्रविष्टि को वास्तविक नाम में बदलें (वैसे भी आप कैसे करना चाहते हैं, वैसे भी)। आप फ़ाइल को अपने पसंदीदा संपादक में संपादित कर सकते हैं, या बस समस्या:

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

एक और। क्या मेरे gitconfig में "(skytreader)" भाग शामिल करना संभव है (इसलिए मुझे एक और जीपीजी कुंजी उत्पन्न करने की आवश्यकता नहीं है)? – skytreader

+6

यह कुछ भी हो सकता है जो आप चाहते हैं। वास्तव में, आप विशिष्ट '' निर्दिष्ट करने के लिए '-u' या' --local-user' झंडे का उपयोग कर सकते हैं (इसे 'git config --global user.signingkey ' – Christopher

35

सबसे पहले आपको यह जांचना होगा कि आपकी आईडी के लिए कोई gpg कुंजी है या नहीं।

$ gpg --list-key 

आप कुछ इस तरह दिखाई देनी चाहिए है:

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

यदि कोई GPG कुंजी। आप बनाना चाहिए

$ gpg --gen-key 

इसके बाद आप इस उत्पादन:

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

आप कोई कुंजी पहले से उत्पन्न है, तो आप अपना Git यूजर आईडी के बीच मिलान के बारे में चिंता किए बिना कि विशिष्ट कुंजी का उपयोग करने Git बता सकते हैं (नाम + ईमेल) और जीपीजी कुंजी की आईडी। आपको अपने गिट user.email अपने हस्ताक्षर किए गए टैग के लिए अपनी जीपीजी कुंजी पर ईमेल में से किसी एक से मेल खाना चाहिए या अन्य उपयोगकर्ताओं के लिए उपयोगी होना चाहिए।

आपके कंप्यूटर पर वैश्विक उपयोग के लिए कुंजी सेट करने के लिए, के साथ अपने Git वैश्विक कॉन्फ़िग सेट:

git config --global user.signingkey 6AB3587A 

या, आप केवल वर्तमान भंडार आप के साथ कर रहे हैं के लिए user.signingkey सेट कर सकते हैं:

git config user.signingkey 6AB3587A 
+0

मैं 'git config --local user.signingkey 6AB3587A' पसंद करता हूं क्योंकि यह सार्वजनिक कंप्यूटर/सर्वर पर है। – dotslash

संबंधित मुद्दे