Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear a GIT Repository

Tags:

git

msysgit

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://[email protected]/reponame.git
git push alias master

but I get the error

To https://[email protected]/reponame.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]/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 ...

like image 633
balexandre Avatar asked Jan 19 '23 01:01

balexandre


2 Answers

I think you are looking for -f flag:

git push -f alias master

It will force remote repository to overwrite master branch.

like image 129
max Avatar answered Jan 26 '23 06:01

max


Just delete the .git directory at the top level of the repository. Then, in that same directory:

git init
git add .
git commit -am 'Initial commit'
like image 42
GarlicFries Avatar answered Jan 26 '23 04:01

GarlicFries