r/github • • May 01 '24

New to GitHub. How does the Blame feature work? 🤔

Post image
297 Upvotes

65 comments sorted by

36

u/Noch_ein_Kamel May 01 '24

git is so negative. in svn you had praise as well ;p

6

u/NicoTorres1712 May 01 '24

Wow so cool haha

3

u/lavahot May 02 '24

What would praise do? Also, git was made by the same guy who made linux, so that's not altogether unsurprising.

5

u/ZZ9official May 02 '24

As he has said - he's an egotist who has written two notable pieces of software and name them both after himself (for the non-commonwealth folks, "git" is slang for an unpleasant and/or incompetent person)

1

u/QuickSilver010 May 03 '24

Pretty sure linus wanted to give a different name for Linux at first. Then some other people just ran with the name.

2

u/ZZ9official May 03 '24

True - he originally planned to call it "Freax" but the ftp site run by his friend called it Linux.

The quote I was thinking of though: "I'm an egotistical bastard, and I name all my projects after myself. First 'Linux', now 'git'."

2

u/Noch_ein_Kamel May 02 '24

Praise does exactly the same. J

3

u/PeteZahad May 02 '24

Would be funnier if it always returns an empty string.

520

u/[deleted] May 01 '24

You see a shit piece of code, blame tells you who last modified it

436

u/[deleted] May 01 '24

And it's usually yourself who committed it. 

174

u/ThunderChaser May 01 '24

It’s always yourself.

56

u/dodexahedron May 02 '24

And if it isn't, yes it is. Just 6 months ago you.

34

u/LilyRudloff May 02 '24

It's not me it's past me!

That guy makes all kinds of mistakes

14

u/DaveR007 May 02 '24

If only that guy knew as much as you do now.

9

u/frisedel May 02 '24

Yesterdays you is an idiot, and future you is a rando we don't care about..

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 dig

32

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

u/boxpretty May 02 '24

And no - it doesn't let you blame someone else

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."

1

u/ImSimplySuperior Nov 26 '24

I'm german and have never heard that. How do you say it in german?

1

u/ojhwel Nov 26 '24

"Nicht gemeckert ist genug gelobt."

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

u/[deleted] May 01 '24

That you workplace gives a damn about useful commit messages

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

u/JalanJr May 02 '24

Send it to Chatgpt inside your hook for "usefulness analysis"

3

u/Ascyt May 02 '24

Goofy ass name for a feature like that

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

u/fergoid2511 May 01 '24

“It wasn’t me”, oh it was….

5

u/perfect9015 May 02 '24

But 6 months ago. 😁

8

u/ISDuffy May 01 '24

If tells you that you wrote this shit code.

Never click it.

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

u/[deleted] May 01 '24

You can point fingers with confidence with this feature

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

u/Wervice May 01 '24

Oh gosh what is this?
Blame: U f**** it up ys
Sh*t

2

u/bikeking8 May 02 '24

This is the developerest shit I ever seen.

2

u/Prudent_Freedom_9427 May 02 '24

ITS ALL YOUR FAULT

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

u/Kind-Kure May 02 '24

It basically just tells you who added which piece of code

1

u/harishvishal May 02 '24

What 's the purpose?

1

u/Empyrealist May 02 '24

Sue's to blame.

1

u/LordNoah73YT May 02 '24

Ig its to find who to blame for shit code

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

u/RngdZed May 01 '24

Blame the new guy

1

u/ferriematthew May 01 '24

I second this question. What does the blame button do anyway?

-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

u/krvnb May 01 '24

It tells about who did commit on each line it was already there in bitbucket

-3

u/[deleted] May 01 '24

For me, Blame is better known as my wife.

1

u/[deleted] May 01 '24

Kennste, kennste

-3

u/AHMADAIMAN18 May 01 '24

You should learn more about GitHub before jump into it

1

u/dm8le May 02 '24

that's the way to learn it. Mess around with it

4

u/[deleted] May 02 '24

[removed] — view removed comment

0

u/[deleted] 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.