I accidentally got a repo in a bad state when trying to move a project from using ant to maven. Now, I would like to clear the repo and startover from scratch. Being new to git, I am a little cautious and not sure if I could just checkout then delete all files and folders locally then push to the remote repo or if that was actually a very bad idea. For some reason I'm having a hard time asking the correct questions in google. :D
3 Answers
Simply remove local .git
directory, remove repo from server (if it is github - do Repo -> setiings -> remove).
Then create new repository on server, and locally do:
git init
git remote add origin git@github.com:user/project.git
git add .
git commit -m "Initial commit"
git push -u origin master
-
1an addition this could use, and use this with caution.
git push -u origin master --force
– JessyMay 21, 2015 at 19:21 -
@Jessycormier There's really no need for
--force
if the repository is removed from the server. It would probably overwrite the repository history if existing repository is used though. May 21, 2015 at 21:33
In my case I just wanted to refresh the local repo, I used Ruslan answer without the last two commands since I didn't need to do anything on the server side, and it worked perfectly! Of course I deleted the .git
file locally as suggested without removing the remote directory before to execute the commands. Thanks!
To delete your repository from GitHub:
.git
dir in your local directory and do agit push --force
to github is the solution I think.