In Bitbucket, we have master branch, and four developer branches, named A, B, C, D. Each branch has 10-100 commits in them. I want to keep the latest code in the respective branches, and start fresh without changing the Bitbucket URL. I would like to remove all the commits from A, B, C, D but leave the lastest code except for one commit in each one.
Here is one way I thought of (and have not tested this idea yet since I am hoping there is a better way).
- I git clone the repo 5 times in different local repos.
- In each of the 5 clones:
- I checkout a different branch - one of the 5 original branches.
- I delete the .git folder.
- I go a git init. (Now I think the master has the latest code in the respective branch.)
- I set origin to the Bitbucket URL
- I create and checkout the respective branch and do a git push to get the branch pushed to Bitbucket.
- I delete the 5 clones.
- I do a git clone to get the latest Bitbucket repo that now has only one commit per branch (I think).
At this point, if any developer looks at Bitbucket in their respective branch, then I hope they would see exactly what they had in there before I completed the above steps (but without history or their commits).
Is there a way to accomplish this goal without having to do a clone 6 times?
Actually, I would rather have nothing in the master branch. I will need to work with the developers to have a common folder tree structure, and then start merging.