Git, edit root commit for all branches

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

git rebase -i

allows you to conveniently edit any previous commits with the exception of the root commit. The following commands show you how to do it manually.

# 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 that I have two branches and several tags already in the repository and I would like my history to be rewritten for those as well. The repo is not public yet, so this is not a problem. I previously asked a similar question , but in this case the command was git rebase

not used. Here is 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 possible?

+2


source to share


1 answer


Use " git filter-branch " instead of git -rebase.



If you really feel like rebase would be better, with modern git you can use the option for git-rebase. Or run root root and then reformat over it if you have an older git that doesn't have this option. --root

+6


source







All Articles