Created
March 24, 2023 18:58
-
-
Save ceaksan/8f4affd9cb66cb60446cb66c11aba449 to your computer and use it in GitHub Desktop.
This file contains 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
#!/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