लोकप्रिय Git config विकल्प
(jvns.ca)-
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 कर देता है।
- ये दोनों settings
-
merge.conflictstyle zdiff3- merge conflicts को अधिक पढ़ने योग्य बनाने वाली setting।
diff3merge 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 truegit rebaseसे पहले और बाद में अपने-आपgit stashऔरgit stash popचलाता है।
-
push.default simple,push.default current- current branch को उसी नाम की remote branch पर अपने-आप push करने के लिए set करता है।
push.default simpledefault setting है, और यह तभी काम करती है जब branch पहले से किसी remote branch को track कर रही हो।push.default currentहमेशा local branch को उसी नाम की remote branch पर push करता है।
-
init.defaultBranch main- नया repository बनाते समय
masterकी जगहmainbranch बनाता है।
- नया repository बनाते समय
-
commit.verbose true- commit message लिखने वाले text editor में पूरा commit diff जोड़ता है, ताकि किए गए काम को याद रखने में मदद मिले।
-
rerere.enabled truegit 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 deltagit 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 truediff.submodule logsubmodule.recurse true
-
अन्य settings
blame.ignoreRevsFile .git-blame-ignore-revsbranch.sort -committerdatecolor.ui falsecommit.cleanup scissorscore.autocrlf falsecore.editor emacscredential.helper osxkeychaindiff.tool difftasticdiff.colorMoved defaultdiff.colorMovedWS allow-indentation-changediff.context 10fetch.prune trueऔरfetch.prunetagsgpg.format sshlog.date isomerge.keepbackup falsemerge.tool meldpush.followtags truerebase.missingCommitsCheck errorrebase.updateRefs true
-
configure करने का तरीका
- आम तौर पर
git config --global NAME VALUEका इस्तेमाल करके set किया जाता है। - किसी option को हटाने के लिए
~/.gitconfigको manually edit करें।
- आम तौर पर
-
इस लेख को लिखने के बाद बदली गई settings
diff.algorithm histogrambranch.sort -committerdatemerge.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 टिप्पणियां
विकल्प को हटाने के लिए
git config --global --unset NAMEकमांड का इस्तेमाल करने का तरीका भी है।अपनी सेटिंग्स जाँचने के लिए
git config --listजोड़ें।मैंने यह अनुभव किया है कि main development environment में तो सेटिंग कर रखी होती है, लेकिन किसी दूसरे environment में वह सेट नहीं होती, तो लगता है कि यह काम क्यों नहीं कर रहा... haha डेवलपर अगर Git रोज़ इस्तेमाल करते हैं, तो अच्छा होगा कि Git settings से जुड़ी चीज़ों में उनकी दिलचस्पी और बढ़े।
Hacker News राय
core.autocrlfऔरsafecrlfसेटिंग्सgitattributesसे override किया जा सकता है.gitconfigमेंaliasसेटिंग्सrebase.autosquashऔरfixupaliaspull.rebaseभी महत्वपूर्ण है, लेकिनfixupका उपयोग अधिक बार होता हैinsteadOfसेटिंग की उपयोगिताadvice.statusHints,include.path,remote "origin".fetch,interactive.singleKeyजैसी विभिन्न सेटिंग्स का उल्लेख.gitconfigसेटिंग्स का उदाहरणalias,tag,tar,log,pull,diff,difftool,pager,safe,advice,initसेटिंग्स शामिल हैंdeltaका उपयोग करने की सेटिंगuser.useConfigOnlyसेटिंगuser.emailको comment out करने के बाद, नए repository में commit करते समय ईमेल सेट करनाmerge.conflictstyleका default बदलने की ज़रूरतdiff3style conflict resolution के लिए अधिक जानकारी देता हैcore.commentChar,alias.newtask,alias.zip,git checkout -,format.pretty,deltaसेटिंग्सbranch.sortसेटिंग को लेकर गलतफ़हमी.gitconfigसेटिंग्स का उदाहरणalias.lg,alias.hist,alias.quick-push,alias.search,user,core,urlसेटिंग्सquick-pushalias के ज़रिए एक सरल workflow परिभाषित किया जा सकता हैऊपर की सामग्री Hacker News comments में उपयोगकर्ताओं द्वारा साझा की गई व्यक्तिगत
.gitconfigसेटिंग्स और उनकी पसंदीदा Git configuration tips का सारांश है। ये सेटिंग्स Git के उपयोग की दक्षता बढ़ाने, कुछ कार्यों को automate करने और user experience को बेहतर बनाने पर केंद्रित हैं।