Skip to content

Instantly share code, notes, and snippets.

@malpinder
Last active February 8, 2017 16:06
Show Gist options
  • Save malpinder/a6d741ffb6377d5011f44c517c18ab1c to your computer and use it in GitHub Desktop.
Save malpinder/a6d741ffb6377d5011f44c517c18ab1c to your computer and use it in GitHub Desktop.
This removes obvious references to the author from a given git repo.
# This removes obvious references to the author from a given git repo.
# This isn't foolproof - you'll have to trust that interviewers won't go digging.
# re-write the branch so that the author email, name, and committer are replaced with the candidate’s reference.
# if there are any branches other than master, you'll need to run that command on those separately.
git filter-branch -f --prune-empty --env-filter 'GIT_AUTHOR_EMAIL=redacted@example.com; GIT_AUTHOR_NAME="XX"; GIT_COMMITTER_NAME="XX"; export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME GIT_COMMITTER_NAME'
# remove any remotes - check what they are called and replace `origin` if necessary
git remote rm origin
# expire the entire reflog
git reflog expire --expire-unreachable=now --all
# run garbage collection on the expired SHAs
git gc --prune=now
# check it worked - shouldn’t be anything of note present in the reflog
git reflog
# sometimes this just... doesn't work and the reflog is still full of the old SHAs. I've had luck trying one or all of the following:
# step one - just try again a few times, make sure things like gitx or other git processess are shut
git gc --aggressive --prune=now
git for-each-ref --format='delete %(refname)' refs/original | git update-ref --stdin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment