Skip to content

Instantly share code, notes, and snippets.

@ArnabXD
Forked from simon04/git.sh
Last active August 2, 2021 07:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArnabXD/4d05fb03c2725cab953a6e7cda56f568 to your computer and use it in GitHub Desktop.
Save ArnabXD/4d05fb03c2725cab953a6e7cda56f568 to your computer and use it in GitHub Desktop.
Git merge/replace orphan branch into main
git checkout --orphan new
# completely rewrite your application in new framework
git merge --strategy=ours --allow-unrelated-histories main
git commit-tree -p HEAD^2 -p HEAD^1 -m "Merge branch 'new'" "HEAD^{tree}"
git reset --hard $OUTPUT_FROM_PREVIOUS_COMMAND
git checkout main
git merge --ff-only new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment