GitHub Edit Code
In this page:
git diff
git diff --staged
git add file_name
git commit -m "message"
Clone करने के बाद Local Working Directory
एक repository clone करना इसकी पूरी history download करता है और हर tracked file की एक working copy को एक local folder में checkout करता है, इसलिए clone करने के तुरंत बाद, working directory, staging area, और remote सब exactly same content रखते हैं।
उदाहरण: The Local Working Directory After Cloning
git clone https://github.com/user/repo.git
git status
Cloned Files में Changes करना
किसी भी text editor या IDE का इस्तेमाल एक cloned file का content बदलने के लिए किया जा सकता है, क्योंकि Git सिर्फ इसकी परवाह करता है कि disk पर क्या है -- किसी tracked file का content last commit से अलग होते ही, Git इसे working directory में modified mark कर देता है।
उदाहरण: Making Changes to Cloned Files
echo "Updated content" >> README.md
git diff से क्या बदला Check करना
git diff current working directory content को last commit के against compare करता है और exact lines print करता है जो add या remove हुईं, जो इसे stage करना है या नहीं decide करने से पहले एक edit review करने का सबसे तेज़ तरीका है।
उदाहरण: Checking What Changed with git diff
git diff
Local Edits Stage और Commit करना
Local edits सिर्फ repository की history का हिस्सा तभी बनते हैं जब उन्हें git add से stage किया जाए और git commit से record किया जाए -- उस point तक, changes सिर्फ working directory में exist करते हैं और अगर folder delete हो जाए तो खो जाएँगे।
उदाहरण: Staging and Committing Local Edits
git add README.md
git commit -m "Update README"
Push करने से पहले Local Edits को Sync में रखना
Local commits push करने से पहले, git fetch (या git pull) चलाना check करता है कि क्या इस बीच remote आगे बढ़ा है, और local काम को latest remote history पर rebase या merge करना एक rejected push से बचाता है और shared history को follow करना आसान रखता है।
उदाहरण: Keeping Local Edits in Sync Before Pushing
git fetch origin
git rebase origin/main
- files edit करना और GitHub से change देखने की उम्मीद करना, जबकि आपको पहले commit और push करना ज़रूरी है।
git addके बादgit diffचलाना और कुछ न देखना, क्योंकि staged changes कोgit diff --stagedचाहिए।- गलत clone में, या गलत folder में एक file edit करना, और
git statusमें change न देखना।
Chapter Quiz — Complete all 11 topics to unlock
0/11 topics done
Complete these topics first: