Git blame Command
In this page:
git blame file_name
git blame -L start,end file_name
File Line Authorship देखना
git blame <file> किसी file की हर line को उस commit hash, author, और date के साथ annotate करता है जिसने इसे last में बदला, जो पूरे commit log को हाथ से खोजे बिना "किसने यह और क्यों लिखा" जानने का सबसे तेज़ तरीका बनाता है।
उदाहरण: Viewing File Line Authorship
git blame file.txt
Specific Line Ranges Check करना
एक बड़ी file पर blame करना हर single line के लिए annotations dump करता है, जो unhelpful है जब आपको सिर्फ कुछ की परवाह हो। git blame -L 20,40 <file> output को lines 20 से 40 तक restrict करता है, आपको सिर्फ उस function या block पर focus करने देते हुए जिसे आप actually investigate कर रहे हैं।
उदाहरण: Checking Specific Line Ranges
git blame -L 20,40 file.txt
Commit Timestamps दिखाना
Default रूप से date column आपके system locale को follow करता है, जो machines में inconsistent हो सकता है। --date=short एक plain YYYY-MM-DD format देता है और --date=raw raw Unix timestamp देता है, दोनों तब उपयोगी हैं जब आपको consistently parse या compare करने में आसान output चाहिए।
उदाहरण: Showing Commit Timestamps
git blame --date=short file.txt
git blame --date=raw file.txt
White Spaces Ignore करना
एक single reformatting commit (जैसे एक indentation change) real authorship history को एक commit के नीचे दबा सकता है जिसने हर line छुई। git blame -w lines attribute करते समय whitespace-only differences ignore करता है, इसलिए blame reformat को पीछे छोड़कर वह commit ढूँढता है जिसने actually logic बदला।
उदाहरण: Ignoring White Spaces
git blame -w file.txt
Copied Code Track करना
जब code same commit history में कहीं और से move या copy किया गया था, plain blame बस उसे credit देगा जिसने copy-paste किया। git blame -C (या ज़्यादा thorough search के लिए -CCC) उस code के origin को और पीछे follow करता है, इसके बजाय उस commit को credit देते हुए जिसने originally इसे लिखा।
उदाहरण: Tracking Copied Code
git blame -C file.txt
- यह मान लेना कि
git blameदिखाता है कि किसने पहले एक line लिखी, जबकि यह दिखाता है कि किसने last में इसे बदला। - इसे किसी person को blame करने के लिए इस्तेमाल करना, जबकि इसका मकसद commit और उसका message ढूँढना है जो बताए कि क्यों।
-Lके बिना एक विशाल file पर इसे चलाना, सैकड़ों lines print करते हुए जबgit blame -L 20,40 file.txtइसे limit कर देता।
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: