title: Git, edit root commit for all branches
body: <p>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 <a href="https://git.wiki.kernel.org/index.php/GitFaq#How_do_I_edit_the_root_commit.3F" rel="nofollow noreferrer">Git Faq</a>:</p>
  
  <blockquote>
    <p><code>git rebase -i</code> allows you to conveniently edit any previous commits, except for the root commit. The following commands show you how to do this manually.</p>
    
    <pre class="lang-bash prettyprint-override"><code># 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
  </code></pre>
  </blockquote>
  
  <p>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 <a href="https://stackoverflow.com/questions/1138960/git-rewriting-history-of-master-branch-and-associated-tags">similar question</a> before, but in that case the <code>git rebase</code> command was not used. Here's a basic graph of my repo:</p>
  
  <pre><code>+  master branch
  |
  |   + topic branch
  |   |
  |   |
  +---+
  |
  |
  |
  +  TAG
  |
  +  Initial commit, the commit I'd like to amend for all branches
  </code></pre>
  
  <p>Is it even possible?</p>