On my local git repo I\'ve got many commits, which include \'secret\' connection strings :-)
I don\'t want this history on github when I push it there.
Essen
You cloned a project and made a ridiculous amount of commits for a new feature, and the time has come to open source it or share it for review. And you don't want anyone to see your commit mess!
The original branch was cloned_branch, your messy commits were on dev branch, and you want to publish your clean work on the public_branch branch.
cloned_branch:SHA0: Implemented X, and Y. (author:authorA)
SHA1: Implemented Z. (author:authorA)
SHA2: Implemented W. (author:authorA)
dev branch and pushed some commits:SHA3: trying to implement Q feature to work..
SHA4: shit, I doesn't work
SHA5: messed up even more! :(
SHA6: GOT IT WORKING!!!!
SHA7: cleanup!
public_branch:git checkout SHA2 -b public_branch # new branch at `authorA`'s last commit
git merge --squash SHA7 # squash commits up to your last one
git commit -m "Implemented Q (author:me)"
Branches cloned_branch and dev remain as before, whilepublic_branch branch contains:
SHA0: Implemented X, and Y. (author:authorA)
SHA1: Implemented Z. (author:authorA)
SHA2: Implemented W. (author:authorA)
SHA8: Implemented Q. (author:me)