Skip to content

Instantly share code, notes, and snippets.

@robinvanemden
Created February 9, 2022 16:16
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 robinvanemden/72a632aa033f9d49c5090118a7343f72 to your computer and use it in GitHub Desktop.
Save robinvanemden/72a632aa033f9d49c5090118a7343f72 to your computer and use it in GitHub Desktop.
#!/bin/bash
default_branch=`basename $(git symbolic-ref --short refs/remotes/origin/HEAD)`
git checkout --orphan tmp
git add -A # Add all files and commit them
git commit
git branch -D $default_branch # Deletes the default branch
git branch -m $default_branch # Rename the current branch to default
git push -f origin $default_branch # Force push default branch to github
git gc --aggressive --prune=all # remove the old files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment