r/github • • Sep 21 '24

New to GitHub. How does the Blame feature work?

Post image
130 Upvotes

71 comments sorted by

191

u/w00tboodle Sep 21 '24

It just lets you know who is responsible (who's to blame), for the lines of code. It lists who made the last change.

102

u/ISDuffy Sep 21 '24

Oh it was me all along.

67

u/Steffi128 Sep 21 '24

As usual.

“What idiot wrote that piece of shit?“ git blame “Oh, the idiot was me. Of course, it's me.“

20

u/rlnrlnrln Sep 21 '24

It's always me. Or DNS.

5

u/ISDuffy Sep 21 '24

I once had to flatten a copy of a repo, and every commit was me flattening, used to have people coming to me to ask about code and it was so hard to know if it was me or someone else, until I went to the old repo.

2

u/puspendert Sep 21 '24

Happened with me this Friday. One production issue, was reviewing the code with manager and other team mates. "Ye kisne likha h idhar, galat h ekdm".. and then the git blame (intelij) exposed me. 🤦‍♂️ Of course I was not able to recall the changes I made.

1

u/Original-Nothing582 Sep 22 '24

Is that a cipher?

2

u/oz1sej Sep 22 '24

No, it's Hindi. "ये किसने लिखा है इधर, गलत ह एक दम" means "Who wrote this, this is all wrong."

2

u/sgtdumbass Sep 25 '24

Ah yes... The phrase inscribed on the One Ring, worn by Saurun, but passed on when Elindel slayed Saurun in battle. It was long believed to say, “One Ring to rule them all, One Ring to find them, One Ring to bring them all and in the darkness bind them.” But alas, upon closer inspection by Golem (who, let’s be honest, has had a lot of time with it), the true inscription was revealed: “ये किसने लिखा है इधर, गलत ह एक दम” — a scathing complaint from some disgruntled ancient scribe. And so, with the phrase misunderstood for centuries, Frodo trekked to Mordor only to realize that instead of the doom of all mankind, the One Ring was really just complaining about someone's sloppy programming.

1

u/Papa-Ge Sep 25 '24

Nvm actually, it's pretty good code when I think about it more

5

u/QuickSilver010 Sep 21 '24

It was me, Barry, I git added your AI keys at super speed so it seemed like you committed peak idiocy without a second thought.

2

u/jech2u Sep 22 '24

I thought it was Agatha all along

1

u/feltpen02 Sep 26 '24

Probably Agatha

6

u/thequestcube Sep 21 '24

It also shows which commit was last associated with each line, allowing you to more easily understand the incentive behind each line

1

u/glorious_reptile Sep 23 '24

We have a guy who squashes all pull requests to main, so...

1

u/ElectricSpice Sep 23 '24

Still useful, blame will lead you to the PR and you can drill down further from there. And PR generally has better context anyways, as you can see the discussion around the code.

0

u/Kylearean Sep 22 '24

Occasionally Git will use someone else's names on our commits. Someone we don't even know at all, and has never contributed to the project.

72

u/regular_lamp Sep 21 '24

You think "what Idiot wrote this???" then you click on that and you see it was either you or alternatively it gets attributed to someone who didn't actually write that code but ran a code formatter on it.

7

u/cowboyecosse Sep 21 '24

Ouch, this hits hard. It’ll be me or the linter. 😁hah, stupid linter. 😅

5

u/cinderblock63 Sep 21 '24

This is why the linter is one of the first things I enable on new projects.

4

u/Zorbane Sep 21 '24

Totally didn't happen to me on Friday...

1

u/-Tesserex- Sep 22 '24

Or someone who hasn't worked here in ten years.

1

u/Masterflitzer Sep 23 '24

let formatter run in ci and open a pr, then it's github's fault

52

u/SuperheropugReal Sep 21 '24

Git blame. Ask Linus why it's called that

21

u/Noch_ein_Kamel Sep 21 '24

If you ask him also ask him why he didn't copy the praise command as well

9

u/[deleted] Sep 21 '24

That's easy, because the only code that deserves praising is the code linus wrote, and yku can't praise your own code

3

u/[deleted] Sep 22 '24 edited Oct 19 '24

payment disagreeable lush depend wrong license capable grey chop slimy

This post was mass deleted and anonymized with Redact

-7

u/_g550_ Sep 21 '24

Linus doesn’t own the thing anymore. It’s Microsoft.

6

u/mcprogrammer Sep 22 '24

The blame command is from git though. GitHub just exposes the same functionality and uses the same name to be consistent.

1

u/exploding_nun Sep 22 '24

It's older than git. Came from Subversion, maybe even older tools.

2

u/The_King_Of_Muffins Sep 22 '24 edited Sep 24 '24

Microsoft has little to do with the development of git. Github is just a tool which implements git's features.

1

u/_g550_ Sep 24 '24

Danke, kamerade.

2

u/Masterflitzer Sep 23 '24

when will people understand that git != github != gitlab

1

u/SuperheropugReal Sep 21 '24

But... he named it Got Blame.

15

u/nile2 Sep 21 '24

Who is to blame for that trashy code

12

u/martinbean Sep 21 '24

It’s not so much a GitHub feature but a Git feature. “Blame” basically just shows you who the person was responsible for the last change to whatever file or line(s) you’re looking at.

13

u/Standard-Customer-58 Sep 21 '24

This Is more generic feature of git. The blame command permit you to understand Who touch the code and when (using the commit id). If you use tools per repository-mining you can do interesting thing with It.

5

u/cinderblock63 Sep 21 '24

Git has the full history of your code. It can walk back, line by line, and show you not only when that particular line was last changed, but also by whom. This can be useful to see whose code you’re stepping on, or who you need to go find and blame for the mistake.

2

u/GeekCornerReddit Sep 21 '24

Basically shows up who and when was edited every line of a specific file

1

u/ferriematthew Sep 21 '24

It tells you who last screwed up the code /j

1

u/i4get98 Sep 21 '24

Works better when you’re working on a team. If not, it’s more of a self loathing button.

1

u/atheros98 Sep 21 '24

When you push bad code and break the system go there and type @YourCoworker

1

u/mattk404 Sep 21 '24

Ai feature that tells you the source of all logic errors, typos and code smells /s

1

u/nekokattt Sep 21 '24

git blame provides this within git itself. It just looks at who last diffed the given lines of code and links back to the commit that did it.

1

u/nekokattt Sep 21 '24

git blame provides this within git itself. It just looks at who last diffed the given lines of code and links back to the commit that did it.

1

u/Charming-Tell1582 Sep 22 '24

Who blame you 😹

1

u/TellGlass97 Sep 22 '24

To blame the idiot who wrote the code (usually you)

1

u/Born-Acanthisitta-88 Sep 22 '24

"This is all your fault!" Like that

1

u/Popotte9 Sep 22 '24

"New"? 🤨

1

u/Jeklah Sep 22 '24

It tells you who made the last change to a line of code.

1

u/badjano Sep 23 '24

tells you who made the commit

1

u/quinnshanahan Sep 24 '24

Does anyone else remember svn praise that did the same thing as blame but was there just in case you were in a good mood

1

u/Significant-Emu-9391 Sep 24 '24

I thought if code doesnt work you click to blame

-1

u/EwyBoy Sep 21 '24

Apparently you are new to taking screenshots too

-4

u/shgysk8zer0 Sep 21 '24

Is that even new? IDK... I almost exclusively work locally + git, and really only use GitHub as a repo host and for pull requests. In git, I've known about blame for like a decade.

8

u/drugmart87 Sep 21 '24

I believe they're saying they are new to GitHub, not that the Git blame feature is new.

-4

u/shgysk8zer0 Sep 21 '24

Maybe. "New to GitHub" lacks a subject, and the next sentence has the subject of the blame feature. I understood it in the same way as "New to GitHub, how does blame work?" (Note the punctuation).

But... Yeah, I can see that.

0

u/Houdinii1984 Sep 21 '24

Lol, I think everyone was with you at first based on the comments. That's where my mind went until you laid it all out for me grammatically, lol.

2

u/shgysk8zer0 Sep 21 '24

I'll never understand why people gang up and downvote my completely benign and transparent comments on dev subreddits. Seriously, why downvote "it was ambiguous, and maybe I misunderstood"?

It's not like I'm wrong (other than maybe how I understood the post). It's not like I'm being mean/rude. The response I gave was perfectly relevant to what I was replying to, and even admitting maybe I had misunderstood the post. There's no reason for it to be downvoted at all.

And why should me saying why I found it to be ambiguous make a difference? "New to GitHub", in fact, does not have a subject, so what you interpret as the subject does, in fact, change the question being asked. It could be "I'm new to GitHub" or "Something new to GitHub".

1

u/Houdinii1984 Sep 21 '24

I thought it was a new feature. I figured they just didn't have it as a button or something. I do blames in my IDE. I'm used to it, though. I guess for those that guessed correctly felt it was obvious.

2

u/shgysk8zer0 Sep 21 '24

OP hasn't responded that I can see. It's still ambiguous at this point as to which guess is correct. In hindsight, "I'm new to GitHub" seems more likely, but "Something new to GitHub" is still possible without more info/context from the author. We don't know which is correct, just guessing.

And that kinda makes it worse. I admitted I may have misunderstood it. If I'm being downvoted for supposedly guessing wrong, it'd imply that others are taking their assumptions as fact.

1

u/Houdinii1984 Sep 21 '24

I think it's funny that GitHub has this button, but it's apparently not that noticeable either way since there aren't legions of people talking about having seen it. I'm sure the OP is a newer user to GH. I just can't believe I've never seen that button in all my time there, lmao. The amount of times I could have used it, lol.

-5

u/jamesaddicted Sep 21 '24

I want sync My files with visual studio code, how we can do?

4

u/haikusbot Sep 21 '24

I want sync My files

With visual studio

Code, how we can do?

- jamesaddicted


I detect haikus. And sometimes, successfully. Learn more about me.

Opt out of replies: "haikusbot opt out" | Delete my comment: "haikusbot delete"

1

u/QuickSilver010 Sep 21 '24

good bot

1

u/B0tRank Sep 21 '24

Thank you, QuickSilver010, for voting on haikusbot.

This bot wants to find the best and worst bots on Reddit. You can view results here.


Even if I don't reply to your comment, I'm still listening for votes. Check the webpage to see if your vote registered!

2

u/ima_coder Sep 21 '24

Use git.