How to remove history of source code in git bitbucket repository?

Hi, I created a repository and I didn't forget to add *.war and *.java to .gitignore file. Now the repository hava growth and my .git file is about 500 megabytes. I search and test some solution and they aren't working for me. I don't want solution to solve the problem. I want to clean problem. I think the best solution is remove all histories of source code of repository and . [ Because it's a team repository, I can't create a new repositories and I don't want to anybody pay to my bad work].

3 answers

1 accepted

We have a guide to doing this if you simply want to scrub out specific files. Read over the document here. If you are looking to start over. You can simply copy all of your current files over to a new directory without the .git or .hg directory and do:

git init

Then, create/adjust your ignore file and then re-add all your data with:

git add -A

Then you can commit

git commit -m "Some commit message"

And then push your content up to Bitbucket again.

git push -u origin master

Thank you Marcus,

git push origin +master

Also the above worked for me. What is difference between origin +master and -u origin master?

The document no longer exists. It links to a document that no longer contains that information.

is it possible to do that with sourcetree?

I did that and then it says me :

error: src refspec master does not match any.

error: failed to push some refs to 'https://x@bitbucket.org/y/x-y-z.git'

I've updated my comment to include more full instructions.

Suggest an answer

Log in or Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

709 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot