Clearing the repository (remote or local) is not something you can actually do in git. Not sure why you would want that. Git init creates a new repository locally. It will fail if you run it on an existing repository.
The error you are getting is about your local HEAD being detached, meaning you are not actually on a branch, probably due to stuff that you did earlier that you declined to mention in your question. If you do a git status it will tell you this.
Fix that by checking out a branch: git checkout master should work on most repositories that have a master branch. That gets you back on the master branch.
Commit doesn't actually push to remote. So even if you were not detached that still wouldn't send your commit remotely but it would simply create the commit in your local git repository, which lives in your .git directory.
Once you have an actual branch with an actual commit you can try pushing to the remote repository. I assume you actually have one and that you actually cloned it at some point. If you did, it is typically called 'origin' and you need to push the commits from your local master branch to the master branch in origin.
git push typically does that job. If that fails, a git push --all (all branches) or a git push origin master (just the master branch).