← Back to Git Course | Chapter 1: Introduction & Setup | Lesson 6 of 7

Git Workflow Overview

Git का workflow एक suitcase pack करने जैसा है: आप अपने room (working directory) में इधर-उधर करते हैं, चुनी हुई चीज़ें bed (staging area) पर रखते हैं, और फिर उन्हें हमेशा के लिए zip up (commit) कर देते हैं।
Syntax
bash
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

bash
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)

bash
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)

bash
git commit -m "Add homepage"

मौजूदा Files Modify करना

पहले से commit की गई एक file edit करना इसे वापस Working Directory में modified की तरह move कर देता है -- Git इसे एक बिल्कुल नया change मानता है, इसलिए उन edits को आपकी अगली commit में शामिल होने से पहले आपको इसे दोबारा git add करना होगा।

उदाहरण: Modifying Existing Files

bash
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

bash
git log
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. एक file edit करना और बिना git add के git commit चलाना, ताकि कुछ भी commit न हो क्योंकि change कभी staged ही नहीं हुआ।
  2. एक file stage करना, इसे दोबारा edit करना, और commit करना, ताकि सिर्फ पहले वाला staged version save हो और बाद वाला edit छूट जाए।
  3. यह मान लेना कि git add change को history में save करता है, जबकि सिर्फ git commit इसे permanently record करता है।
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.