In some settings, I am used to using git locally, and then exporting a diff which is then submitting with a detailed description. Thus, when I develop locally, I commit constantly, and don’t bother with meaningful commit messages or perfect testing before committing.
However, when using git to publish code on github, I would prefer to erase the history of those little commits and create just one commit that represents logical well-tested change.
What would be the best way to achieve this, without changing my local workflow of committing whenever I feel like I’ve explored a little path (however unproven)?
If you look at “Trimming GIT Checkins/Squashing GIT History“, you can:
git rebase --interactive --fixupfor squashing a commit you would have manually reordered in the commit edit list of arebase --interactive, while ignoring the second commit message, which will make the message edition step faster (you can just save it: the squashed commit will have the first commit message only)git rebase --interactive --autosquashfor making the commit reordering process automatically for you.That is why I like to pick a standard comment for all the micro-commits I make, per activity.
The first micro-commit will contain “my activity”.
All the other will contain “
squash! my activity”Several activities (set of micro-commits) can be intertwined in this process.
All there is left for you is a
git rebase --interactive --autosquashfor all those micro-commits to be reordered and then squashed.The OP namin mentions the blog post Our Git Workflow: Private Development, Public Releases as a good illustration, base on
git merge --squash:(see also:
merge --squashandrebase?)