Git New Files
In this page:
git status
git add new_file_name
git add file1 file2
Untracked Files और git status
एक newly created file जिसके बारे में Git को कभी नहीं बताया गया untracked कहलाती है -- git status इसे modified tracked files से अलग, इसके अपने 'Untracked files' heading के तहत list करता है, ताकि आप exactly देख सकें कि disk पर क्या exist करता है लेकिन अभी repository की history का हिस्सा नहीं है।
उदाहरण: Untracked Files and git status
git status
एक Single नई File Add करना
एक file path के बाद git add चलाना उस single file को untracked या modified state से staging area में move कर देता है, इसे अगली commit में शामिल होने के लिए mark करते हुए बिना इस समय untracked या modified किसी दूसरी file को affect किए।
उदाहरण: Adding a Single New File
git add index.html
कई नई Files Add करना
एक command में spaces से separated git add के बाद कई file paths list किए जा सकते हैं, या *.css जैसे shell wildcard से match किए जा सकते हैं, जो हर file के लिए एक अलग git add command की माँग करने के बजाय एक साथ pattern से match करने वाली हर file stage कर देता है।
उदाहरण: Adding Multiple New Files
git add file1.txt file2.txt
git add *.css
git add . से सभी नई Files Add करना
git add . current directory और इसकी सभी subdirectories में मिली हर नई और modified file stage करता है, जबकि git add -A आगे जाकर deletions सहित पूरी repository stage करता है, चाहे command किसी भी directory से चलाया जाए।
उदाहरण: Adding All New Files with git add .
git add .
git add -A
यह Check करना कि क्या Commit होगा
Commit करने से पहले, git status summarize करता है कि कौन सी files staged हैं और कौन सी अभी भी untracked या modified हैं, और git diff --cached exact line-by-line content दिखाता है जो staged किया गया है, आपको precisely confirm करने देते हुए कि अगली commit में क्या record होगा।
उदाहरण: Checking What Will Be Committed
git status
git diff --cached
- एक file बनाने के तुरंत बाद
git commitचलाना, जबकि एक नई file untracked है और पहलेgit addचाहिए। git add *.txtइस्तेमाल करना और subfolders में files की उम्मीद करना, जबकि shell pattern सिर्फ current directory से match करता है जब तकgit add '*.txt'जैसे quoted न हो।- एक ऐसी file add करना जो
.gitignoreमें पहले से list है, ताकि Git एक message के साथ मना कर दे जब तक आप-fइस्तेमाल न करें।
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)