This question already has an answer here:
As a hobbyist developer I'm quite keen on the git-flow way of working.
But I keep having a problem that I can only blame myself for: while developing a new feature, I keep getting sidetracked by small things that I can "quickly" do. Such things range from small refactoring, writing a particular piece of code in a more pythonic way, adding comments, decoupling, writing an extra test, etc.
Of course, next to the fact that these small things are unrelated to the feature I'm developing, they also tend to grow in size. What appears to be a small thing to do turns out to be something that you spend 2 hours on.
Are there any best practices to keep myself from doing this? I have tried forcing myself to switch to the development branch and do the fixes in a seperate hotfix branch, but I always fool myself into thinking that "for this little change, it's unnecessary to bother with a new branch". Is this just a question of discipline?
(Bonus question: I'm a sole developer, but how on earth would a team of developers handle someone like me? In other words: I'd be changing code all over the place, all the time, which would mean my co-developers would have to keep checking out code and keep trying to get their heads around the new changes).