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.

  • Says it commits, but in GitHub it doesn't show up
  • git crlf configuration in mixed environment
  • EGit out of sync
  • Multi-user Github Pull Requests
  • Jenkins loses workspaces periodically, triggers unwanted build
  • When is git rm -f used?
  • # 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?

  • Ignoring Hidden Files git
  • Visual Studio 2013 - Source control only for one project
  • How to get a detached repository working
  • How to set a git branch to push to a remote with a different branch name and pull from completely different url
  • Gitlab API for all projects under group
  • Git: Getting someone elses project without forking
  • 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.