r/github • u/NicoTorres1712 • May 01 '24
New to GitHub. How does the Blame feature work? 🤔
520
May 01 '24
You see a shit piece of code, blame tells you who last modified it
436
May 01 '24
And it's usually yourself who committed it.
174
u/ThunderChaser May 01 '24
It’s always yourself.
56
34
8
u/TheBoatyMcBoatFace May 02 '24
It’s always DNS
2
u/drcforbin May 02 '24
And just this morning, while debugging an issue with our prod system accessing a new service, I caught the culprit and pulled off their mask...
It was DNS, claiming it would've gotten away with it too if not for that pesky
dig32
u/ender42y May 01 '24
"alright who inserted this shit so i can go ask them what the hell they were thinking... oh, it was me... what the hell was I thinking?!?"
7
6
u/Bloodsucker_ May 01 '24
False. It's just a button to get somebody fired. Don't press it guys cause it might be you 😨
163
u/latkde May 01 '24
That's a graphical frontend for the git blame feature, also known as git annotate. It looks through the commit history of a file, and then shows for each line what commit last changed it. This is useful for finding out:
who wrote this code? (thus, who to "blame")
when and why was this part changed?
83
u/wjrasmussen May 01 '24
Note: There is no praise
75
u/ojhwel May 01 '24
There is a German workplace saying, "Not complaining is praise enough."
11
6
1
6
u/ReplacementLow6704 May 01 '24
When it was changed? Sure. Why it was changed? The commit says "wip", what should I extrapolate from that?
5
5
u/Front-Difficult May 01 '24
That you should write a git hook to enforce meaningful commit messages.
5
u/user-74656 May 02 '24
fix: FAKE-6969 Addsada dadassda das Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus ac metus pharetra augue lobortis semper. Proin non ipsum mi. Suspendisse quis diam hendrerit nibh aliquet lobortis. Aliquam sit amet nulla congue, mattis risus at, malesuada elit. In eleifend, tortor sed consequat dictum, lacus elit gravida turpis, sit amet finibus est tellus tristique dui. Changelog:
- Nothing
- No thing
- Nowt
3
3
58
u/naikrovek May 01 '24
This is a git thing, not a GitHub thing, GitHub just puts a UI over it. But as others have said, it shows who last committed a change to each line in the file.
21
u/nihillistic_raccoon May 01 '24
A button that makes you sad whenever you want to check who commited an abomination and it usually turns out to be you Usually not even that long ago
15
8
6
u/GraceMiste May 01 '24
The Blame feature in GitHub helps track changes in a file, showing who last modified each line, offering insights into code history and accountability."
4
u/dodexahedron May 02 '24 edited May 02 '24
It's for quickly doing what people who aren't familiar with it do manually: Finding out when (in what commit) a certain change happened. Instead of going to a file, getting its history, and manually looking through the diffs, let the machine do it for you.
That's especially helpful when the change that did it isn't in your history for whatever reason (maybe it was copied or force pushed from elsewhere instead), because then you don't waste time going through 50 commits only to find it was that way from the beginning.
Key is it's blaming a commit/change, not a person. Though of course a person ultimately is tied to the change.
I'd have called it something else both clearer and without as negative a connotation, but that's Linus for ya.
3
3
u/Cybasura May 02 '24
Literally the most apt name - it tells you who to blame for the monstrocity
It's always you
5
2
2
2
u/warengonzaga May 03 '24
You'll see the last person commited to a piece of code. It is actually a command from git called git blame.
1
1
1
1
1
u/tech_w0rld May 06 '24
Something most didn't mention is blame also shows what was most recently modified as well as who made that change
1
u/Necessary-Speed-1955 Oct 20 '26 edited Oct 20 '26
Ran git blame like you asked. It's you. It's always you.
1
1
-1
u/chihuahuaOP May 01 '24
It saves the name of the last user that committed the code. VS code github copilot extension shows the commit message and date very useful if you aren't sure about the code my favorite was a commit with "fuck this" 3 years ago.
7
u/ItalyPaleAle May 01 '24
Note it’s the GitLens extension in VS Code that shows annotations with the blame.
-3
-3
-3
4
May 02 '24
[removed] — view removed comment
0
May 02 '24
[deleted]
1
u/StandingBehindMyNose May 03 '24
Exactly. u/NicoTorres1712 could literally copy and paste the words they wrote into Google and get an answer faster and more complete than what this Reddit post got.
36
u/Noch_ein_Kamel May 01 '24
git is so negative. in svn you had praise as well ;p