Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Insert commit as first, allowing rebase of initial commit
# first you need a new empty branch; let's call it `newroot`
git checkout --orphan newroot
git rm --cached -r .
# then you apply the same steps
git commit --allow-empty -m 'initial commit'
# or add some files for the first commit
git add .
git commit -m 'initial commit'
git rebase --onto newroot --root master
git branch -d newroot
# if you have another files is required to do this
git rebase --skip
# and finally
git push --force
git branch -D newroot
You can’t perform that action at this time.