Git Workflow Overview
In this page:
git status
git add file_name
git commit -m "commit message"
तीन Areas
किसी Git project की हर file किसी भी moment पर तीन areas में से एक में बैठती है: Working Directory आपके raw edits रखता है, Staging Area उन changes को रखता है जिन्हें आपने deliberately अगली commit के लिए चुना है, और Repository permanently saved history रखता है -- इस flow को समझना लगभग हर Git command समझने की key है।
उदाहरण: The Three Areas
git status
Changes Track करना (git add)
git add वह command है जो किसी file की current state को Working Directory से Staging Area में move करता है, इसे ready mark करते हुए। अभी history में कुछ भी save नहीं हुआ -- staging बस आपका Git को यह बताना है कि अगले snapshot में कौन से changes साथ belong करते हैं।
उदाहरण: Tracking Changes (git add)
git add index.html
Changes Commit करना (git commit)
git commit -m "message" इस समय staged हर चीज़ लेता है और इसे आपके project की history में एक नए snapshot की तरह permanently record करता है। यहाँ एक clear, specific message मायने रखता है -- अब से छह महीने बाद, वह message अक्सर इकलौता context होगा जो आपके पास यह जानने के लिए होगा कि एक change क्यों किया गया।
उदाहरण: Committing Changes (git commit)
git commit -m "Add homepage"
मौजूदा Files Modify करना
पहले से commit की गई एक file edit करना इसे वापस Working Directory में modified की तरह move कर देता है -- Git इसे एक बिल्कुल नया change मानता है, इसलिए उन edits को आपकी अगली commit में शामिल होने से पहले आपको इसे दोबारा git add करना होगा।
उदाहरण: Modifying Existing Files
echo "Updated" >> index.html
git status
git add index.html
History Log Review करना
git log current branch पर अब तक की गई हर commit से वापस चलता है, सबसे नई पहले, हर एक के लिए author, date, और message दिखाते हुए -- यह 'इस project के साथ actually क्या हुआ, और कब' का जवाब देने का primary तरीका है।
उदाहरण: Reviewing the History Log
git log
- एक file edit करना और बिना
git addकेgit commitचलाना, ताकि कुछ भी commit न हो क्योंकि change कभी staged ही नहीं हुआ। - एक file stage करना, इसे दोबारा edit करना, और commit करना, ताकि सिर्फ पहले वाला staged version save हो और बाद वाला edit छूट जाए।
- यह मान लेना कि
git addchange को history में save करता है, जबकि सिर्फgit commitइसे permanently record करता है।
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: