Created
January 29, 2020 13:28
-
-
Save dreammonkey/7983e0fd212c09e3d11f40bb7d3b12bc to your computer and use it in GitHub Desktop.
git: backup master branch and start form empty master
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; clone the repo | |
git clone <repository> | |
; make sure HEAD is master (optional) | |
git checkout master | |
; make a local backup of master branch | |
git branch -m master master_backup | |
; push local backup branch to server | |
git push -u origin master_backup | |
; checkout master using --orphan | |
git checkout --orphan master | |
; do a hard reset (removes all files) | |
git reset --hard | |
; create a readme (for initial commit) | |
touch README.md | |
; make changes and commit | |
git add . | |
git commit -m 'Initial commit' | |
; push new master to server using force | |
git push origin master --force | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment