59 पॉइंट द्वारा GN⁺ 2024-02-17 | 4 टिप्पणियां | WhatsApp पर शेयर करें
  • pull.ff only या pull.rebase true

    • ये दोनों settings git pull चलाते समय branch के upstream branch से अलग होने पर गलती से merge commit बनने से रोकने के लिए हैं।
    • pull.rebase true हर बार git pull --rebase चलाने के बराबर है।
    • pull.ff only हर बार git pull --ff-only चलाने के बराबर है।
    • दोनों settings को साथ में इस्तेमाल करने का कोई मतलब नहीं है, क्योंकि --ff-only, --rebase को override कर देता है।
  • merge.conflictstyle zdiff3

    • merge conflicts को अधिक पढ़ने योग्य बनाने वाली setting।
    • diff3 merge conflict दिखाने के default तरीके को बदलता है और बीच में original code दिखाता है।
    • zdiff3, diff3 का बेहतर version है और आम तौर पर इसे अधिक अच्छा माना जाता है।
  • rebase.autosquash true

    • पुराने commit को संशोधित करना आसान बनाने वाली सुविधा।
    • git commit --fixup OLD_COMMIT_ID के साथ commit करने पर git rebase --autosquash main चलाते समय fixup! commit अपने target के साथ अपने-आप जुड़ जाता है।
  • rebase.autostash true

    • git rebase से पहले और बाद में अपने-आप git stash और git stash pop चलाता है।
  • push.default simple, push.default current

    • current branch को उसी नाम की remote branch पर अपने-आप push करने के लिए set करता है।
    • push.default simple default setting है, और यह तभी काम करती है जब branch पहले से किसी remote branch को track कर रही हो।
    • push.default current हमेशा local branch को उसी नाम की remote branch पर push करता है।
  • init.defaultBranch main

    • नया repository बनाते समय master की जगह main branch बनाता है।
  • commit.verbose true

    • commit message लिखने वाले text editor में पूरा commit diff जोड़ता है, ताकि किए गए काम को याद रखने में मदद मिले।
  • rerere.enabled true

    • git rebase के दौरान merge conflicts को कैसे resolve किया गया था, यह याद रखता है और अपने-आप conflicts resolve करता है।
  • help.autocorrect 10

    • Git की autocorrect सुविधा typo को पहचानती है, लेकिन corrected command को अपने-आप execute नहीं करती।
    • अगर इसे अपने-आप execute कराना हो, तो help.autocorrect को 1, 10, immediate, या prompt पर set करें।
  • core.pager delta

    • git diff, git log, git show आदि के output को दिखाने के लिए इस्तेमाल होने वाला "pager"।
    • delta इसे syntax highlighting वाले उन्नत diff viewer के रूप में set करता है।
  • diff.algorithm histogram

    • default diff algorithm अक्सर function के क्रम बदलने पर समस्या पैदा करता है।
    • diff.algorithm histogram इसे अधिक स्पष्ट तरीके से दिखाता है।
  • core.excludesfile: global .gitignore

    • सभी repositories पर लागू होने वाली global gitignore file की setting।
  • includeIf: personal और work के लिए अलग Git settings

    • personal और work repositories के लिए अलग email address configure करने में उपयोगी।
  • url."git@github.com:".insteadOf 'https://github.com/'

    • https://github.com को अपने-आप git@github.com: से बदल देता है।
  • fsckobjects: data corruption से बचाव

    • data corruption को सक्रिय रूप से detect करने वाली setting, जिसने टीम को कई बार बचाया।
  • submodule से जुड़ी settings

    • status.submoduleSummary true
    • diff.submodule log
    • submodule.recurse true
  • अन्य settings

    • blame.ignoreRevsFile .git-blame-ignore-revs
    • branch.sort -committerdate
    • color.ui false
    • commit.cleanup scissors
    • core.autocrlf false
    • core.editor emacs
    • credential.helper osxkeychain
    • diff.tool difftastic
    • diff.colorMoved default
    • diff.colorMovedWS allow-indentation-change
    • diff.context 10
    • fetch.prune true और fetch.prunetags
    • gpg.format ssh
    • log.date iso
    • merge.keepbackup false
    • merge.tool meld
    • push.followtags true
    • rebase.missingCommitsCheck error
    • rebase.updateRefs true
  • configure करने का तरीका

    • आम तौर पर git config --global NAME VALUE का इस्तेमाल करके set किया जाता है।
    • किसी option को हटाने के लिए ~/.gitconfig को manually edit करें।
  • इस लेख को लिखने के बाद बदली गई settings

    • diff.algorithm histogram
    • branch.sort -committerdate
    • merge.conflictstyle zdiff3
  • समापन

    • बहुत से लोगों से उनकी पसंदीदा settings पूछकर सबसे अधिक उल्लेखित options की सूची बनाना उपयोगी है।

GN⁺ की राय

  • इस लेख की सबसे महत्वपूर्ण बात यह है कि इससे डेवलपर्स द्वारा अक्सर इस्तेमाल किए जाने वाले Git config options के बारे में पता चलता है।
  • Git का उपयोग करने वाले शुरुआती software engineers के लिए ये settings काम की efficiency बढ़ाने और रोज़मर्रा की समस्याएँ हल करने में मददगार हो सकती हैं।
  • खास तौर पर merge.conflictstyle zdiff3 या rebase.autosquash true जैसी settings merge conflicts को resolve करने और commit history को manage करने को आसान बनाती हैं, जिससे collaboration के दौरान आने वाली समस्याएँ कम हो सकती हैं।

4 टिप्पणियां

 
pril1 2024-02-23

विकल्प को हटाने के लिए git config --global --unset NAME कमांड का इस्तेमाल करने का तरीका भी है।

 
rumbarum 2024-02-21

अपनी सेटिंग्स जाँचने के लिए

git config --list जोड़ें।

 
pmc7777 2024-02-18

मैंने यह अनुभव किया है कि main development environment में तो सेटिंग कर रखी होती है, लेकिन किसी दूसरे environment में वह सेट नहीं होती, तो लगता है कि यह काम क्यों नहीं कर रहा... haha डेवलपर अगर Git रोज़ इस्तेमाल करते हैं, तो अच्छा होगा कि Git settings से जुड़ी चीज़ों में उनकी दिलचस्पी और बढ़े।

 
GN⁺ 2024-02-17
Hacker News राय
  • core.autocrlf और safecrlf सेटिंग्स
    • CRLF फ़ाइलों के commit को रोकना और LF में conversion को force करना
    • ज़रूरत पड़ने पर gitattributes से override किया जा सकता है
  • .gitconfig में alias सेटिंग्स
    • commit history को एक संक्षिप्त graph के रूप में दिखाने के लिए alias सेट करना
    • Stack Overflow पोस्ट से लिया गया कॉन्फ़िगरेशन
  • rebase.autosquash और fixup alias
    • अक्सर इस्तेमाल की जाने वाली सेटिंग्स, जो commit के बाद rebase को automate करती हैं
    • pull.rebase भी महत्वपूर्ण है, लेकिन fixup का उपयोग अधिक बार होता है
  • insteadOf सेटिंग की उपयोगिता
    • GitHub remote जोड़ते समय shorthand का उपयोग
    • advice.statusHints, include.path, remote "origin".fetch, interactive.singleKey जैसी विभिन्न सेटिंग्स का उल्लेख
  • व्यक्तिगत .gitconfig सेटिंग्स का उदाहरण
    • इसमें अलग-अलग alias, tag, tar, log, pull, diff, difftool, pager, safe, advice, init सेटिंग्स शामिल हैं
  • pager के रूप में delta का उपयोग करने की सेटिंग
    • ज़्यादा पढ़ने योग्य और syntax-highlighted diff दिखाता है
    • default branch पर checkout करने के लिए alias जोड़ना
  • कई ईमेल इस्तेमाल करने के लिए user.useConfigOnly सेटिंग
    • user.email को comment out करने के बाद, नए repository में commit करते समय ईमेल सेट करना
  • merge.conflictstyle का default बदलने की ज़रूरत
    • diff3 style conflict resolution के लिए अधिक जानकारी देता है
  • अतिरिक्त सेटिंग्स
    • core.commentChar, alias.newtask, alias.zip, git checkout -, format.pretty, delta सेटिंग्स
  • branch.sort सेटिंग को लेकर गलतफ़हमी
    • वास्तव में यह सबसे हाल में उपयोग की गई branch के बजाय commit date के अनुसार sort करती है
  • एक और व्यक्तिगत .gitconfig सेटिंग्स का उदाहरण
    • alias.lg, alias.hist, alias.quick-push, alias.search, user, core, url सेटिंग्स
    • quick-push alias के ज़रिए एक सरल workflow परिभाषित किया जा सकता है

ऊपर की सामग्री Hacker News comments में उपयोगकर्ताओं द्वारा साझा की गई व्यक्तिगत .gitconfig सेटिंग्स और उनकी पसंदीदा Git configuration tips का सारांश है। ये सेटिंग्स Git के उपयोग की दक्षता बढ़ाने, कुछ कार्यों को automate करने और user experience को बेहतर बनाने पर केंद्रित हैं।