Asumming we have a fully tracked repo under main.
We follow these steps:
See method 3 here
Then when we want to push, we do:
git push prasasti latest:main --force (credit & source)
- Whereby we force-push from an orphan branch (in this case I used
latestbranch) into themainbranch in a remote repo I calledprasasti
My complete history
git checkout --orphan latest
git status # check the files to remove
git rm -rf 02-04* # remove the desired files and directory
git status # double check
git commit -m "clean slate." # the clean slate commit
git log # check that there is only the previous single commit there
git push -f prasasti main # this command returns 'Everything up-to-date', which I DO NOT WANT, but then I found this
git push prasasti latest:main --force # this one works! (force-push into the remote directory prasasti content of the clean-slate latest local branch into remote main branch.
git checkout main # return to main
git branch -D latest # delete the temporary branch
I re-do the above steps and still working.