简体   繁体   中英

Git clear remote repository

If I push a bad initial commit (or more than one) to a remote repository and want to just clear it / destroy it - can I do it by a command?

It's important to totally remove it from server so it doesn't use disk space.

EG Today I pushed a whole Visual Studio project with included dlls, sdfs and so on. Firstly this files are quite big, secondly some of them are modified by VS of other developers and than can't be merged. This made me google a little bit and I found out these files should be ignored. But the first commit already clutters my repository. I want to remove this and free the disk space.

It's possible to remove git repo and add it again via host's website (assembla), but this doesn't sound like solution to me.. Is there a more professional way?


UPDATE:

I tried suggestions from the answer below but it didn't work: 'git push -f' 'git push --force' 'git push origin -f' 'git push origin --force' resulted in:

$ git push --force
Counting objects: 19, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (19/19), done.
Writing objects: 100% (19/19), 6.85 KiB, done.
Total 19 (delta 3), reused 0 (delta 0)
remote: error: denying non-fast-forward refs/heads/master (you should pull fir
)
To git@git.assembla.com:xxxxx.git
 ! [remote rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@git.assembla.com:xxxxx.git'

You can force push the "correct" repo with git push -f . Depending on the host, the loose objects will be cleaned up when git gc is ran. update: According to this you can't force the git gc in assembla.

If you want them cleaned up immediately and assembla doesn't allow you to force a git gc , the other option is to delete the repo and push a new one.

In addition, as Ryan stated in the comments, be sure to let everyone know that may have cloned the repo, that you re-wrote history.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM