Mac and Linux, Why I'll never go back to Windows
I wrote recently, that after my most recent experience on Windows, specifically Windows 7.
I’ve been having discussions with friends & colleagues of late about Git’s interactive rebasing feature.
I’ve been having discussions with friends & colleagues of late about Git’s interactive rebasing feature.
If you’re not familiar with it, interactive rebasing is a feature unique to Git, which allows a developer to manipulate their commit history in a variety of ways, including:
It supports this – even if the work’s been pushed to remote repositories. For me – it’s a standout feature!
From time to time I see people take issue with it, believing that it has no place in a version control system. I completely disagree, with one strict caveat: don’t rewrite history – EVER!
This might sound a little counter to what I’ve said so far. What I mean is, change your history around to your heart’s content – but never after it’s pushed. That’s akin to ripping the rug out from under your young child, who’s just taken her first steps. A dramatic analogy perhaps, but it indicates the importance of what is and is not acceptable.
Imagine it happened to you. You were working on a feature then pulled code only to see history all rewritten. What would your feelings be of the colleague who did it? Not too positive I’m sure. There must be consistency.
It’s been oft said:
Computers do really well at steps which need to be repeated the same way, repeatedly – but humans don’t.
That’s the key reason for me for its inclusion. Despite our best efforts, discipline, attention to detail, we make mistakes, we overlook things, forget, we can be over-worked and stressed. As a result, we can be inconsistent, forget steps we’ve done a thousand times, or fail to see the glaringly obvious.
Source code management systems that don’t offer this flexibility, consequently, necessitate so high a level of discipline as to be unrealistic. It’s not to say that excellent apps can’t be written with them; they can, are and have been for many years.
But git’s interactive rebasing offers an approach more akin to how we, as people, operate. It is forgiving of our mistakes, allowing us to fix or tidy up our work before sending code out into the world.
You’ve been working away all day and a number of files were involved. But not all the changes related to the same task.
You work through the changes, committing the relevant hunks and commit, with “A Note About Git Commit Messages” – a proper commit message. You do the same for the next change and commit again. Then, when preparing for the last change, you spot a file, a hunk, a changed line, which belongs to the first change.
Now yes, you could make another commit and when someone pulled your changes, they’d have everything. But I’m a firm believer in work being atomic, being all-inclusive, being self-contained. They shouldn’t be interspersed through multiple commits.
Because of this, it’s a personal rule of mine, before pushing changes, to always give my work a once over. I review all commit messages and commit contents asking myself these questions:
If I can answer yes to all of these questions, then I’m happy to push the work out.
This is why git interactive rebasing is a key feature and should be available to all developers. We aren’t perfect creatures. But we can use tools that forgive our mistakes and help us bridge the gap. Tell me what you think. Rant, critique, find fault. But share your thoughts.
I wrote recently, that after my most recent experience on Windows, specifically Windows 7.
How many apps do you have installed on your computer? 10, 20, 100? How many of them did you buy
Please consider buying me a coffee. It really helps me to keep producing new tutorials.
Join the discussion
comments powered by Disqus