We are moving some repositories from GitHub to BitBucket and we do not want to delete the ones in GitHub because we still have some issues in their issue tracker. We are waiting for this bug to be solved so we can correctly export the issues. So for now we just want to delete all the history of the repository and insert as the initial commit a very small README.md file.
2 Answers
Copy your working directory to a new directory.
Inside that directory do a
git init; git add.; git commit -m 'First Commit Message'
If you want publish this new repo to one of your remote servers, just add the server as remote with
git remote add remote-name remote-URL
and then agit push remote-name
to upload things to the remote that you just add to the new repo and update that remote with the content of this new repo.In the case that the remote already has things on the
master
branch, you could need to-f
orce push:git push -f remote-name

- 115,751
- 26
- 228
- 437
Use this:
$ git reset --hard `git rev-list --max-parents=0 HEAD`
$ git rm -r '*'
then one of the following:
$ git commit --amend --allow-empty
or if you want with a README file, use this, but before, please replace vim
with your preferred text/code editor and instead of README.md
use what name you want for the initial commit's single file:
$ vim README.md
$ git add README.md
$ git commit --amend
I wrote this answer with help from this, this and this StackOverflow answers.

- 3,343
- 3
- 31
- 57
-
1You could also just initialise a new repo, add the single file, set the same remote and force push it. – jonrsharpe Sep 01 '17 at 19:14
-
@jonrsharpe I tried your method and it functions well. Thanks. – silviubogan Sep 01 '17 at 19:23