Reputation: 1663
How can I totally wipe out everything in a Git remote repository? I am the only client currently and before I can let it go public I have to wipe out all of the previous commits.
This question is about how to remove history, including the original base commit, without deleting the existing repository. My repository is on SourceForge, and the only way to do that is to destroy the whole project, which requires you to submit a Project Removal Request, which they don't always grant (especially in my case, where my project is younger than 90 days, so they won't grant it).
Upvotes: 2
Views: 7108
Reputation: 1441
Here's a simple way to do that :
Create an empty git repository.
git init
Make a dummy commit :
touch README.md
git add README.md
git commit -m "first commit"
Reference the repo you want to overwrite :
git remote add origin REMOTE_URL
Overwrite remote git
git push --force origin
Remove existing remote tag (one by one)
git push --delete origin TAG_NAME
Upvotes: 0
Reputation: 8300
Use git push command to delete branch
$git push origin :remotebranch_name
this will delete remote branch completely
Upvotes: 0
Reputation: 84343
You have to have at least one commit on a branch in order to push it to a remote repository. If you have no heads at all, git won't have anything to send to origin. You can resolve this by making an empty branch with an empty commit. For example:
git symbolic-ref HEAD refs/heads/empty_branch
rm .git/index
git commit --allow-empty -m 'Initialize empty branch.'
git branch -M empty_branch master
git push --force origin
When you're done, both your current master and origin/master will contain exactly one file-free commit. The underlying objects in the repositories will eventually be reaped when git performs garbage collection.
If you want to delete all local and remote tags, you can push a set of empty references to the remote before deleting the tags locally. For example:
# Delete all tags present on the local host from the remote
# host in one push operation.
git for-each-ref --format=':%(refname)' --shell refs/tags |
xargs git push origin
# Delete all local tags.
git tag -d $(git tag)
Upvotes: 3
Reputation: 169008
If the remote name is origin
and you have force-push rights on the remote repository, this will delete every branch and every tag in the remote repository:
REMOTE=origin
for i in .git/refs/$REMOTE/origin/*
do
git push $REMOTE :"`basename "$i"`"
done
for i in `git tag`
do
git push $REMOTE :refs/tags/$i
done
This is a destructive operation, so make sure that you really want to do this first.
Upvotes: 1
Reputation: 31050
ssh to the server and do a rm -rf .git
within the project directory. If you want to then put it under git again, run a git init
.
Upvotes: 1