using git workflows to avoid loosing intermediate changes
A few days ago a buddy, Jean, had stumbled into a problem caused by infrequent committing to his git repository. Committing after the feature is implemented is common when working with tools like SVN… but we have multiple workflows available to us under git to manage frequent commits.
Here are some examples of things I’ve used and seen people do…
-
the commit and amaend workflow
hack
git commithackgit commit --amendhackgit commit --amendHere the
amendsteps will combine new work with the first commit. The intermediate work is still accessible via reflog. -
the interactive rebase workflow
hack
git commithackgit commithackgit commithackgit rebase -i HEAD~3The last step is intended to reorder and merge commits as you see fit. You’d usually cleanup only those commits that have yet to be shared, because that avoids doing extra merges.
-
hack
git commithackgit commithackgit commithackgit reset HEAD~3cleanupgit commitHere we discard the last 3 commits and recombine the edits into a new commit.
… by far this is a non exhaustive list.
Anyway, I am writing this so I can introduce something I started working on today called [git wip]{save-everything-with-git-wip}.