I.e., I have:
root -- c1 -- c2 -- .. - c1000 -- c1001 -- c1002 -- .. -- c2000 -- top
and I want to have:
root = c1000 -- c1001 -- c1002 -- .. -- c2000 -- top
How?
(I guess I can do via git filter-branch
, but how exactly?)
(Of course I know that this means history-rewriting...)
If you commit sensitive data, such as a password or SSH key into a Git repository, you can remove it from the history.
To remove the last commit from git, you can simply run git reset --hard HEAD^ If you are removing multiple commits from the top, you can run git reset --hard HEAD~2 to remove the last two commits. You can increase the number to remove even more commits.
I have found the below useful for creating new repos with a different root ( which is what I think you are asking when you say remove history before a commit):
git fast-export master~5..master | (cd ../newrepo.git && git init . && git fast-import && git checkout)
(you can do the above in the same repo too)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With