Git init Command
In this page:
git init [directory_name]
git init -b branch_name
git init क्या है?
git init वह single command है जो किसी भी ordinary folder को एक active Git repository में बदल देता है -- यह object database, refs, और configuration रखने वाली hidden .git directory बनाता है जो Git को changes track करना शुरू करने के लिए चाहिए।
उदाहरण: What is git init?
git init
एक Empty Repository Initialize करना
आप एक बिल्कुल नई directory बनाने और इसे एक step में एक repository की तरह initialize करने के लिए git init <folder-name> भी चला सकते हैं, जो scratch से एक project शुरू करते समय एक मौजूदा folder convert करने के बजाय handy है।
उदाहरण: Initializing an Empty Repository
git init my-new-project
Custom Default Branch
नई repositories को एक starting branch name चाहिए, और modern Git आपको git init -b main (या init.defaultBranch के through एक global default set करके) से explicitly इसे चुनने देता है बजाय installed default जो भी हो उसे accept करने के।
उदाहरण: Custom Default Branch
git init -b main
एक Repository को दोबारा Initialize करना
पहले से एक repository वाले folder के अंदर दोबारा git init चलाना पूरी तरह safe है -- Git आपकी मौजूदा commits या files को नहीं छूएगा, यह सिर्फ किसी भी missing configuration files को दोबारा बनाता है, जो कभी-कभी एक corrupted setup repair करने के लिए उपयोगी है।
उदाहरण: Re-initializing a Repository
git init
एक Bare Repository Initialize करना
एक bare repository, git init --bare से बनाई गई, में checked-out files की कोई working directory बिल्कुल नहीं होती -- यह सिर्फ raw tracking data रखती है, जो exactly वह है जो आप एक server पर चाहते हैं जो पूरी तरह एक central hub की तरह act करे जिसे दूसरे push और pull करें।
उदाहरण: Initializing a Bare Repository
git init --bare
- पहले से एक Git repository वाले folder के अंदर, या एक parent folder में
git initचलाना, ताकि project structure गलत तरीके से track हो। - यह उम्मीद करना कि
git initपहली commit या files बनाएगा, जबकि यह सिर्फ empty.gitfolder बनाता है। - यह surprise होना कि पुराने setups पर branch का नाम
masterहै, जबकि आपgit init -b mainसे नाम चुन सकते हैं।
Chapter Quiz — Complete all 18 topics to unlock
0/18 topics done
Complete these topics first:
- Git init Command
- Git New Files
- Git Staging Environment
- Git clone Command
- Git status Command
- Git help Command
- Git add Command
- Git commit Command
- Git tags Command
- Git stash Command
- Git log Command
- Git diff Command
- Git show Command
- Git rm Command
- Git mv Command
- Git restore Command
- Git clean Command
- Git ignore (.gitignore)