Git diff Command
In this page:
git diff
git diff --staged
git diff commit1 commit2
Unstaged Changes देखना
बिना arguments के git diff आपकी Working Directory में हर वह change दिखाता है जो अभी staged नहीं हुआ, आपकी current files को staging area में पहले से मौजूद के against line-by-line compare करते हुए (या last commit, अगर कुछ भी staged न हो)।
उदाहरण: Viewing Unstaged Changes
git diff
Staged Changes देखना
git diff --staged (या equivalent --cached) opposite view दिखाता है: exactly क्या आपकी अगली commit में जाने वाला है, staging area को आपकी last commit के against compare करते हुए -- actually commit करने से ठीक पहले का review step।
उदाहरण: Viewing Staged Changes
git diff --staged
दो Commits Compare करना
git diff <commit1> <commit2> आपके project की history में किन्हीं भी दो points को सीधे compare करता है, चाहे वे कितने भी दूर हों या किन branches पर हों, आपको उनके बीच पूरा accumulated difference देखने देते हुए।
उदाहरण: Comparing Two Commits
git diff a1b2c3d e4f5g6h
Commits में Files Compare करना
किसी diff command में एक file path append करना -- git diff commit1 commit2 -- path/to/file -- comparison को सिर्फ उस एक file तक narrow करता है, जो एक पूरी commit में changes scroll करने से कहीं ज़्यादा आसान पढ़ता है।
उदाहरण: Comparing Files Across Commits
git diff a1b2c3d e4f5g6h -- path/to/file.txt
Word-Level Diff
Default रूप से git diff पूरी बदली हुई lines highlight करता है भले ही सिर्फ एक word अलग हो; git diff --word-diff इसके बजाय एक line के अंदर बदले specific words highlight करता है, जो prose या लंबे single-line statements के लिए कहीं ज़्यादा clear है।
उदाहरण: Word-Level Diff
git diff --word-diff
git addके बादgit diffचलाना और कुछ न देखना, क्योंकि यह working directory को staging area से compare करता है;git diff --stagedइस्तेमाल करें।git diffकोgit statusसे confuse करना, जबकिgit diffline-level changes दिखाता है औरgit statusसिर्फ file names दिखाता है।-और+lines को उल्टा पढ़ना, जबकि-एक हटाई गई line mark करता है और+एक add की गई।
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)