For the back story, I have a number of github accounts, one is used for code I use while blogging, another is for internal projects at work, and yet another was for a client I was working on. A while back I noticed that I had commits that apparently were done with my "client" github account that showed up in my blog.
Confused, I verified my public/private key pairs against what was in github and was truly stumped as to how this was happening. While scratching my head, I remembered that there is the concept of a "global" config in git and ran the following command:
git config --global -l
Uh oh! it turns out I had a global config set... When I went back and looked, EVERY commit I had done was as this erroneous user.
The problem seems common to distributed source code revision management systems, but is fundamental to git. Every copy of every repository is trusted to maintain it's own copy of revision history. After realizing this, I also realized that I could rewrite history, push to the central repository and effectively delete and/or amend the revision history in the master repository.
As an example, I tried the following:
git clone git@github-personal:mikemainguy/mainguy_blog.git git config --replace-all user.name Scooby git config --replace-all user.email firstname.lastname@example.org echo "Scooby Doo" >> README git commit -a git push
Now when examining the history in github, my commit shows up as having come from some cat named scooby doo! Worse yet, there's no apparent way to figure out which github account actually pushed the change.
Worse yet, I can rewrite history in my local repository, push it out and make old changes disappear and nobody will be able to see what happened.
echo "SECRET STUFF" >> README2 git add README2 git commit README2 -m "whoops" git pushCheck your central repo, you see README2
git filter-branch --index-filter 'git rm --cached --ignore-unmatch README2' -f git push
Now check github, the commit is still there (I'm not sure if that can be completely removed), but the file is gone... It's as if it never existed!
So, applying this knowledge to my screwed up commits I ran the following:
git filter-branch --env-filter 'export GIT_AUTHOR_NAME=Mike Mainguy' -f git filter-branch --env-filter 'export GIT_COMMITTER_NAME=Mike Mainguy' -f git filter-branch --env-filter 'export GIT_AUTHOR_EMAILemail@example.com' -f git filter-branch --env-filter 'export GIT_COMMITTER_EMAILfirstname.lastname@example.org' -fAnd all the craziness is gone...
Knowing these details is important if you're using git/github because most people coming from a centralized source code control tool would find this behavior a little bit disconcerting (if not just plain wrong). The thing to remember is that every person you trust to push to your repository can effectively remove/rewrite history to their own liking. If accountability and audit trail are important, you'll likely need to adopt a "pull" model and have someone manually verify/rewrite each commit.