Search code examples
gitmsysgit

How to clear a GIT Repository


In Tortoise SVN there is a Repo-Browser where we can simply delete all files and add new files again.

How can we do this in GIT?

repo is not hosted in GITHub and there is no interface apart of the repo url

Why?

I created a local repo and pushed into the remote host, but realized after that was in the wrong directory, so, locally it's easy, just

git init 
git add .
git commit -m "New place commit;"

git remote add alias https://user@domain.com/reponame.git
git push alias master

but I get the error

To https://user@domain.com/reponame.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'user@domain.com/reponame.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.

Witch is fine as I'm pushing a new repo ... so I just want to clear the remote one in order to be able to push this new one ...


Solution

  • I think you are looking for -f flag:

    git push -f alias master
    

    It will force remote repository to overwrite master branch.