← Back to Git Course | Chapter 1: Introduction & Setup | Lesson 4 of 7

Git Configuration

Git configuration अपने school notebook पर अपना नाम लिखने जैसा है ताकि सबको पता चले यह किसका काम है। जब तक Git को आपका नाम और email न पता हो यह आपको एक version save नहीं करने देगा।
Syntax
bash
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
git config --global core.editor "editor_name"

अपना Username Set करना

Git आपको तब तक commit नहीं करने देता जब तक उसे पता न हो कि आप कौन हैं, इसलिए अपनी पहली commit से पहले आप git config --global user.name से globally अपना name set करते हैं, और वह name permanently आपके save किए हर snapshot में bake हो जाता है।

उदाहरण: Setting Your Username

bash
git config --global user.name "Your Name"

अपना Email Set करना

अपने name के साथ, Git हर commit पर आपका email address भी record करता है -- यही वह value है जो cookiescursor.com जैसे platforms आपकी commits को आपके account से match करने के लिए इस्तेमाल करते हैं, इसलिए double-check करना उचित है कि यह वहाँ registered से match करता है।

उदाहरण: Setting Your Email

bash
git config --global user.email "[email protected]"

Default Editor Set करना

जब किसी command को आपको एक message type करने की ज़रूरत हो (जैसे एक interactive commit), Git जो भी text editor आपने configure किया है उसे launch करता है -- Nano beginner-friendly है, Vim एक बार सीखने पर तेज़ है, और अगर आप एक GUI पसंद करें तो VS Code को default set किया जा सकता है।

उदाहरण: Setting the Default Editor

bash
git config --global core.editor "code --wait"

अपनी Configurations List करना

git config --list चलाना Git के इस समय इस्तेमाल कर रहे हर active setting print करता है, साथ में हर एक किस config file से आई इसके साथ, जो यह debug करने का सबसे तेज़ तरीका है कि जब behavior आपकी उम्मीद से match न हो तो 'Git ऐसा क्यों कर रहा है'।

उदाहरण: Listing Your Configurations

bash
git config --list

Configurations का Scope

Git configuration तीन scopes में layered है: --system machine पर हर user पर apply होता है, --global सिर्फ आपके user account पर apply होता है, और --local सिर्फ current repository के अंदर apply होता है -- conflict होने पर local settings global वालों को override करती हैं।

उदाहरण: Scope of Configurations

bash
git config --system --list
git config --global --list
git config --local --list
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. git config --global user.name और user.email skip करना, ताकि commits गलत या guessed identity दिखाएँ या Git commit करने से मना कर दे।
  2. --global छोड़ देना ताकि setting सिर्फ एक repository पर apply हो और अगली repository फिर पूछे।
  3. अपने GitHub account email से अलग एक email इस्तेमाल करना, ताकि commits आपकी profile से link न हों।
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.