2

We have an Assembla remote repo. Assembla doesn't offer free private repos now, so we want to re-use one of our old ones. The repo has a master branch and a lot of files/commits.

How can we get rid of everything, including all files and history, to allow us to start again with a new project?

First I have an up-to-date pull of the repo.

I tried deleting the remote master branch thusly:

git push origin :master.

This gives the error :

remote: error: By default, deleting the current branch is denied, because the next remote: error: 'git clone' won't result in any file checked out, causing confusion.

So I tried creating a new branch, pushing it, then from the other branch deleting master, thusly:

git checkout -b tempy
git push origin tempy
git push origin :master

I get the same error.

I could switch back to master, delete all the files locally, then commit and push, but his leaves a lot of unwanted history.

Any ideas?

random
  • 9,774
  • 10
  • 66
  • 83
John Little
  • 10,707
  • 19
  • 86
  • 158

2 Answers2

6

The simplest answer is to remove/delete your current project and start a new one.

OR the only other way would be to force a push

rm -rf .git
git init
git add .
git commit -m "Initial commit"
git remote add origin <your-assembla-git-url>
git push -u --force origin master
Oliver Atkinson
  • 7,970
  • 32
  • 43
  • By project, do you mean repo? I cant delete the repo, as assmebla.com doesnt allow you to create new ones any more (well ti does, but only with 2 users). I just need a way of deleting the files and idealiy history. One can usually delete remote branches, so I thought I could delete the master branch, but it seems this is not allowed. – John Little May 16 '13 at 16:22
  • @JohnLittle I have updated my answer, this will remove your history and push a blank one up there. – Oliver Atkinson May 16 '13 at 16:26
  • Hi Oliver, tried you solution. When try and push, says "remote error: denying non-fast-forward refs/heads/master (you should pull first)...! [remote rejected] master -> master (non-fast-forward) error: failed to push some refst to 'git@... Any suggestions appreciated... – John Little May 16 '13 at 21:07
  • 1
    HAHA, it works! there is a setting in assembla.com which is "allow --force push". Ticked this and it worked! Back to a bare repo. Oliver is the git God. Am writing this recipe down! – John Little May 16 '13 at 21:13
1
git checkout master
git reset --hard <commit> # where commit is SHA of first commit in history
git push origin master

or remove .git completely from your local repo and redo git init, see https://stackoverflow.com/a/16502899/368552

Community
  • 1
  • 1
Luke Hutton
  • 10,612
  • 6
  • 33
  • 58