Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How do I delete all repository content so I can start from GIT INIT again?

Jamie Garvey
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 24, 2023

Due to other factors, updates to particular development projects had to be done in a way where the projects were not associated with the original Bitbucket repository.  In order to upload the code, we need to remove the current content in the repository in a way that allows us to  just do a GIT INIT with the entirety of the code.

What steps should we follow to remove all repository content so we can do a GIT INIT with a repository?

2 answers

0 votes
Jamie Garvey
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 30, 2023

Thanks @Saxea _Flowie_.  Quick question.  We are trying to do just the delete part on the BitBucket side.  Then we will do the Init from our development tool.  We need to delete first as the functions within our development tool don't offer the -f equivalent.  

Are those steps just for the deletion/reset of the repo or are they facilitating the INIT as well?  It's the delete/reset that we need.  Are these functions we can perform from the BitBucket front end?  Thanks very much for your response and support.  Jamie

Saxea _Flowie_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 30, 2023

You can't "delete" in git, but you can replace the history using the -f(force). So these are the steps to replace content. Even if you "delete" by replacing with an empty repository, to "upload" the code you will the to replace the empty repository again.

I don't  think you can "replace" the content from Bitbucket interface. The closest to this would be to delete and re-create the repo - which I assume you don't want to do it.

Are those steps just for the deletion/reset of the repo or are they facilitating the INIT as well?

It does the init as well. However, if you prefer, you can do everything from your tool and just do the push -f from the command line. Typically, there's no difference whether it's done via GUI or command line; you can mix and they interop fine.

0 votes
Saxea _Flowie_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 24, 2023

Something like this should do it. Key thing is to use '-f' when pushing, to override the content on the remote:

rm -rf .git
git init
git add .
git commit -m "Initial commit"
git remote add origin <remote_repository_url>
git push -f origin main

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events