What does UserA committed with UserB 13 days ago on github mean?

GitGithub

Git Problem Overview


I am interested in knowing which one of the two users made the file changes when github lists both. The git record contains only UserA however.

Git Solutions


Solution 1 - Git

UserA is the one who actually made the changes. UserB is the one who committed those changes to this branch. i.e if UserA commits his changes to branch1, UserB comes, commits a couple changes to branch2, rebases branch1 with branch2. Now, topmost commits in branch1 will show that UserA has committed these changes with UserB.

Edit: This mainly happens during rebasing and cherry-picking, since authors and committers can be different in these processes.

Solution 2 - Git

@venkatKA's answer is accurate and descriptive but I thought I'd add a few details.

git cat-file -p HEAD can be used to print out information about the commit

tree d85ed3c3a055c95445898a5119ea0a532459fdsf
parent 0b6ed951b2c04b4134c91ffa053b4330edfdffc1
author AuthA <autha@email.com> 1487356245 +0000
committer AutbB <aubt@email.com> 1487356245 +0000

If you want to fix historic committers (for example if you are changing your identity) then you can use:

git filter-branch -f --tree-filter "GIT_COMMITTER_NAME='New Author'; GIT_COMMITTER_EMAIL='New Author'" 

The standard comments about rebases breaking history and why revisionism is a bad idea apply.

Solution 3 - Git

Another one of possible reasons behind this happening is by using $GIT_AUTHOR_NAME and $GIT_AUTHOR_EMAIL env variables.

When these variables are set, they override the author part of every onward commit no matter what user.name and user.email config values are set locally. In this case, when you hit git cat-file -p HEAD, author shows value of $GIT_AUTHOR_NAME and committer shows value of local user.name configuration.

So you'll need to remove lines that export these variables in .bashrc or .zshrc, or if you want to preserve those lines but just don't want this thing happen, insert unset GIT_AUTHOR_NAME && unset GIT_AUTHOR_EMAIL before running git commit.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMichaelView Question on Stackoverflow
Solution 1 - GitvenkatKAView Answer on Stackoverflow
Solution 2 - GitAtt RighView Answer on Stackoverflow
Solution 3 - GitelquimistaView Answer on Stackoverflow