- Git repository के भीतर मौजूद कुछ खास फ़ाइलों के जरिए अपने काम करने का तरीका नियंत्रित करता है, और ये
.git/ के अंदर की settings नहीं बल्कि commit होकर code के साथ चलने वाली फ़ाइलें होती हैं
.gitignore, .gitattributes, .lfsconfig, .gitmodules, .mailmap आदि क्रमशः फ़ाइल tracking से बाहर रखना, attributes तय करना, LFS settings, submodule management, author mapping का काम करते हैं
.git-blame-ignore-revs और .gitmessage code formatting commits को ignore करने और commit message template देने के जरिए collaboration की quality बेहतर बनाते हैं
- GitHub, GitLab, Gitea आदि
.github/, .gitlab/, .gitea/ जैसी platform-specific config folders के जरिए CI/CD, reviewer assignment जैसी सुविधाओं का विस्तार करते हैं
- यही संरचना Git से आगे बढ़कर EditorConfig, Docker, language version management tools आदि में भी लागू होती है, जिससे dotfile-आधारित automatic configuration ecosystem बनता है
Git की प्रमुख मैजिक फ़ाइलें
- Git
.gitignore, .gitattributes, .lfsconfig, .gitmodules, .mailmap जैसी कई special files को पहचानकर repository के behavior को नियंत्रित करता है
- ये फ़ाइलें
.git/ के अंदर की settings नहीं बल्कि commit होकर साझा की जाने वाली configuration हैं, जो collaboration के दौरान consistent behavior सुनिश्चित करती हैं
.gitignore
- उन file patterns को परिभाषित करता है जिन्हें Git को track नहीं करना चाहिए
- wildcard(
*.log), directory(dist/), negation(!important.log) आदि को support करता है
.gitignore, .git/info/exclude, global settings(~/.config/git/ignore) के क्रम में लागू होता है
- जो फ़ाइलें पहले से tracked हैं, वे
.gitignore जोड़ने के बाद भी tracked रहती हैं, और git rm --cached से हटाई जा सकती हैं
- GitHub, GitLab, Gitea आदि ignored patterns वाली फ़ाइलों को भी बिना warning के commit करने देते हैं
- GitHub language-specific
.gitignore templates official repository में उपलब्ध कराता है
.gitattributes
- हर फ़ाइल के लिए filter, diff, merge, line endings, language detection आदि नियंत्रित करता है
- उदाहरण:
*.psd filter=lfs, *.png binary, *.sh text eol=lf
text line ending normalization करता है, binary diff/merge को disable करता है, और merge=ours conflict की स्थिति में local version बनाए रखता है
- GitHub Linguist
.gitattributes पढ़कर language statistics से exclusion, generated code folding, documentation exclusion आदि करता है
- हर directory के
.gitattributes और .git/info/attributes दोनों को पहचानता है
.lfsconfig
- Git LFS settings को repository के साथ साझा करता है
.gitattributes में LFS से process होने वाली फ़ाइलें तय होती हैं, और .lfsconfig server location जैसी detailed settings संभालता है
- मौजूदा committed फ़ाइलों को LFS में ले जाने के लिए
git lfs migrate command चाहिए
.gitmodules
- submodule configuration information को स्टोर करता है
git submodule add पर बनता है और git submodule update के समय संदर्भित होता है
git clone करते समय submodules अपने-आप नहीं आते; --recurse-submodules option चाहिए
- version range tracking का समर्थन नहीं करता, और nested
.git directories बनने जैसी कमियाँ हैं
.mailmap
- author name और email को एकीकृत रूप से प्रबंधित करता है
git log, git shortlog, git blame आदि में unified नाम से दिखाता है
- GitHub का contributors graph mailmap को reflect नहीं करता
- location को
.mailmap या mailmap.file setting से तय किया जा सकता है
.git-blame-ignore-revs
git blame में ignore किए जाने वाले commits की सूची निर्दिष्ट करता है
git config blame.ignoreRevsFile .git-blame-ignore-revs से enable किया जाता है
- GitHub, GitLab(15.4+), Gitea इसे अपने-आप पहचानते हैं
- फ़ाइल न होने पर error आ सकता है, इसलिए empty file बनाए रखना recommended है
.gitmessage
- commit message template को परिभाषित करता है
- उदाहरण:
# <type>: <subject>
#
# Types: feat, fix, docs, style, refactor, test, chore
git config commit.template .gitmessage से setting करनी होती है
- clone के बाद manual setup चाहिए होता है, और कुछ teams husky आदि से इसे automate करती हैं
- विकल्प के तौर पर
commit-msg hook या prepare-commit-msg hook इस्तेमाल किए जा सकते हैं
Platform-specific extension folders
- GitHub, GitLab, Gitea, Forgejo, Bitbucket आदि अपने अलग configuration folders इस्तेमाल करते हैं
.github/, .gitlab/, .gitea/, .forgejo/, .bitbucket/
- इनमें CI/CD workflows, issue·PR templates, CODEOWNERS files आदि शामिल होते हैं
- Forgejo
.forgejo/ → .gitea/ → .github/, और Gitea .gitea/ → .github/ क्रम में fallback करता है
- SourceHut
.build.yml या .builds/*.yml इस्तेमाल करता है
अन्य प्रचलित फ़ाइलें
- .gitkeep: Git empty directories को track नहीं करता, इसलिए directory बनाए रखने के लिए dummy file के रूप में इस्तेमाल होती है
- .gitconfig: project-specific Git settings का उदाहरण दे सकती है, लेकिन अपने-आप load नहीं होती
- .gitsigners: GPG/SSH signing keys की सूची प्रबंधित करती है,
gpg.ssh.allowedSignersFile से specify किया जा सकता है
- .gitreview: Gerrit code review server की settings file
- .gitlint: commit message linting rules को परिभाषित करता है
- .jj/: Git-compatible VCS Jujutsu की state directory, जो
.git/ के साथ मौजूद रह सकती है
Git से आगे का dotfile ecosystem
- .editorconfig: अलग-अलग editors के बीच consistent code style बनाए रखता है
- indentation, line endings, encoding, trailing whitespace removal आदि को परिभाषित करता है
- VS Code, Vim, Emacs जैसे प्रमुख editors इसका support करते हैं
- .ruby-version, .node-version, .python-version: language version management tools(rbenv, nodenv, pyenv आदि) इन्हें पढ़कर अपने-आप switch करते हैं
- .tool-versions: asdf की multi-language version management file
- .dockerignore: Docker build के दौरान exclude की जाने वाली फ़ाइलों की सूची तय करता है
.gitignore जैसा ही pattern syntax इस्तेमाल करता है, build speed बढ़ाता है और secrets को बाहर रखता है
Git integration tools बनाते समय ध्यान देने योग्य बातें
- Git repositories को संभालने वाले tools को इन फ़ाइलों को ज़रूर पहचानना चाहिए
.gitignore: file traversal के दौरान ignore patterns लागू करना
.gitattributes: binary और generated files में अंतर करना
.mailmap: author information को unified रूप में दिखाना
.gitmodules: submodule handling
- Git config file format
[section "subsection"] key = value संरचना का होता है, और इसे git config command से पढ़ा-लिखा जा सकता है
- ज़्यादातर languages की Git libraries इस format को parse करने की क्षमता देती हैं
अभी कोई टिप्पणी नहीं है.