DEV Community

Cover image for Git Credibility: How to Steal the Spotlight (and Credit) in Collaborative Coding.
KARTHIK NARAYAN
KARTHIK NARAYAN

Posted on

Git Credibility: How to Steal the Spotlight (and Credit) in Collaborative Coding.

Coding with your colleagues can be a rollercoaster ride of collaboration and shared caffeine-induced hysteria. Sometimes, you find yourself in a situation where you've practically co-authored a piece of code, but the official credit seems to be slipping through your fingers. Fear not, dear programmers, for we have uncovered the secret to rewriting commit history and claiming your well-deserved 15 milliseconds of coding fame!

The Case of the Vanishing Commit Credit

Imagine you and your colleague, Bob, have been burning the midnight oil to conquer a particularly pesky coding challenge. You've been sharing debugging insights, writing lines of code together, and practically finishing each other's Git commands. As the exhilarating moment approaches to immortalize your shared efforts with a Git commit, you realize your colleague might walk away with all the commit credit! Shock! Horror!. For me, it's a nightmare.

Unearthing the Git-gredient

Enter the mystical world of Git commit messages, where you can wield the power of co-authorship! With a single command, you can ensure that both you and Bob get the recognition you deserve. It's like writing your names on the digital chalkboard of history, for everyone to see.

1. Pair Programming Commit

When you and your colleague are pair programming and making the commit together on one machine, you can use the "Co-authored-by" trailer in the very first commit message. Here's an example of how to structure the commit message:

git commit -m "update done

Co-authored-by: Your Name <your@email.com>
Co-authored-by: Your Colleague's Name <colleague@email.com>"
Enter fullscreen mode Exit fullscreen mode

This way, you're attributing both authors right from the start.

Or

2. The Co-authored-by Concoction

First, Bob creates a commit with his changes using the classic:

git commit -m "Implemented feature ABC"
Enter fullscreen mode Exit fullscreen mode

Now, it's your turn to shine. To make sure your contributions don't go unnoticed, you'll craft a commit message with an added twist:

git commit -m "Implemented feature ABC

Co-authored-by: Your Name <your@email.com>
Enter fullscreen mode Exit fullscreen mode

You've added a "Co-authored-by" trailer, and in it, you've bestowed upon yourself and Bob the honor you so richly deserve. Replace "Your Name" and "your@email.com" with your actual details and watch as the magic unfolds.

The Big Reveal

With the combined forces of your commits, you're ready to unleash your code upon the world! Don't forget to push your changes to the remote repository:

git push origin your-branch
Enter fullscreen mode Exit fullscreen mode

The Final Act

As the code reviewers scroll through the commit history, they'll see your names side by side, like a dynamic duo of coding comedy. Your colleagues will admire your teamwork, your commitment to sharing the credit, and your excellent sense of humor (after all, you did read this blog, right?).

Top comments (2)

Collapse
 
syeo66 profile image
Red Ochsenbein (he/him)

When you really have to think about such things you might consider leaving the team or company...

Collapse
 
karthiknarayan profile image
KARTHIK NARAYAN

It's not always about company or team, it's just our self satisfaction, looking at code and seeing our name as author.
Not for everyone, atleast for me it matters.