Skip to content

Instantly share code, notes, and snippets.

@mike1011
Last active August 1, 2020 01:25
Show Gist options
  • Save mike1011/e490871f3150cf6bef8215ac74ff8667 to your computer and use it in GitHub Desktop.
Save mike1011/e490871f3150cf6bef8215ac74ff8667 to your computer and use it in GitHub Desktop.
Push existing code to new fresh repo
To begin with, firstly create a new repository on github WITHOUT INITIALIZING it.
## clean up existing repo
rm -rf .git
## re-initialize it with new .git settings
git init
## firstly, dont commit any code, just create/add new sample/readme file and push it to new repo/master
git add README.md
## add newly created fresh repo
git remote add origin [email protected]:username/my-new-master-repo.git
git commit -m "first commit"
git push -u origin master
## verify and then if its successful, push remaining files
git status
## get latest readme/sample file you pushed to get in sync with new master/repo
git pull origin master
## add all now
git add .
git commit -m "first project push"
git push origin master
----- Done -----
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment