How to attribute another author when you're committing on git?

ztickm

Salim MAHBOUBI

Posted on May 7, 2018

How to attribute another author when you're committing on git?

Why?

You might find yourself in a situation where you have to commit some code that has been authored by someone else. They might not have access to the repo, or they might be accustomed to Bazaar/SVN/Mercurial but not git, or maybe they're just on a 3 years vacation.
If you commit with the default global or project config, git will present you as the author.
You should not want that to happen for two reasons:
1- You might take credit for someone else's work and that's unethical.
2- You might take blame for their shitty code and that's bad.

How?

For a new commit attributing another person, use this command:

git commit --author="Ms. Jane Codeldoe <Jane@Codeldoe.com>" -m "Jane wrote this I'm just committing"
Enter fullscreen mode Exit fullscreen mode

How it looks on GitHub:
Screenshot showing that a commit on Github

For older commits, it's a bit more complicated, you want to avoid being in this kind of situations.
But, there are solutions, you just need to do some good old googling (or Binging, or Duckduckgoing, whatever suits you).
Solutions might vary depending on whether the commit is pushed to remote or not.
Solutions also vary depending on the git hosting service you're using, I've seen GitHub specific solutions that might not work elsewhere.

P.S
If you're stuck with this kind of problem, or any other problem you think I might be able to help solve, please contact me at msalim [at] boun.cr . I'll be glad to help with my humble know-how.

๐Ÿ’– ๐Ÿ’ช ๐Ÿ™… ๐Ÿšฉ
ztickm
Salim MAHBOUBI

Posted on May 7, 2018

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

ยฉ TheLazy.dev

About