Skip to content

Instantly share code, notes, and snippets.

@ceaksan
Created March 24, 2023 18:58
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 ceaksan/8f4affd9cb66cb60446cb66c11aba449 to your computer and use it in GitHub Desktop.
Save ceaksan/8f4affd9cb66cb60446cb66c11aba449 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Get the current remote URL
remote_url=$(git config remote.origin.url)
# Get account and repo name from remote URL
account=$(echo $remote_url | cut -d/ -f4)
repo=$(echo $remote_url | cut -d/ -f5 | cut -d. -f1)
# Construct the GitHub URL
github_url="https://github.com/$account/$repo.git"
# Remove the history
rm -rf .git
# Recreate the repository from the current content only
git init
git add .
git commit -m "Initial commit"
# Add the converted GitHub URL as the new origin
git remote add origin $github_url
# Pull any changes from the remote repository
git pull origin master
# Push to the GitHub remote repository
git push -u origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment