Git, edit root commit for all branches

I have to rewrite the history of my repository because it contains some credentials. As I have to amend the root commit I followed the instructions from Git Faq:

git rebase -i allows you to conveniently edit any previous commits, except for the root commit. The following commands show you how to do this manually.

  • Is there a difference between git mv and the MS-DOS move?
  • How to install git repository on Bluehost
  • Troubles with shebang in gitolite hooks
  • How to move a git repository from 1 hard drive to another
  • How does Git create unique commit hashes, mainly the first few characters?
  • Accidentally ran git stash pop twice
  • # tag the old root
    git tag root `git rev-list HEAD | tail -1`
    git checkout -b new-root root
    # edit...
    git commit --amend
    # check out the previous branch
    git checkout @{-1}
    # replace old root with amended version
    git rebase --onto new-root root
    # cleanup
    git branch -d new-root
    git tag -d root

    My problem is though that I have two branches and several tags already in the repository and I’d like that my history rewrite to apply to those too. The repo isn’t public yet, so that wouldn’t be a problem. I’ve asked a similar question before, but in that case the git rebase command was not used. Here’s a basic graph of my repo:

    +  master branch
    |   + topic branch
    |   |
    |   |
    +  TAG
    +  Initial commit, the commit I'd like to amend for all branches

    Is it even possible?

  • Cannot push to heroku after adding a remote heroku repo to my existing local repo
  • How to get rid of Git submodules untracked status?
  • Git error - gpg failed to sign data
  • git pull says “Already up to date” after undoing a git pull
  • git diff two files on same branch, same commit
  • What does git “updating currently checked out branch” warning mean?
  • One Solution collect form web for “Git, edit root commit for all branches”

    Use “git filter-branch” instead of git-rebase.

    If you really, really feel that rebase would be better, with modern git you can use --root option to git-rebase. Or cherry-pick root commit, and then rebase on top of it, if you have older git that doesn’t have this option.

    Git Baby is a git and github fan, let's start git clone.