Skip to content

Instantly share code, notes, and snippets.

@bmunoz89
Forked from framon/rebase_first_commit.sh
Last active October 9, 2022 18:39
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmunoz89/db9c6c371686301ba005e0e407835f74 to your computer and use it in GitHub Desktop.
Save bmunoz89/db9c6c371686301ba005e0e407835f74 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment