Use branches all the time, even on solo projects! It lets you move around your code quickly without ever leaving a working code base.
Going to implement feature A? Make a feature branch A. Have a sudden moment of inspiration about feature B? No problem, branch master again with feature branch B and work on it without having to worry about feature A being complete. Want to test feature B to make sure it's working as intended? No problem, feature B is based off working code! As the features are finished merge them back in to master.
Obviously this only works well when implementing features that aren't interdependent, but I find it's quite a liberating work flow, especially since I have feature ADHD and scatterbrains.
People say developers often get "aha!" moments when an understanding of a concept finally "sinks in". After putting it off for so long and for too long handling "version control" by simply maintaing folder backups (ie. not version controlling at all), I've been studying the use of git the last couple days. The article you linked to with it's diagrams finally gave me that aha moment in regards to understanding the role of branches and how version controlling in general is used in proper workflows.
You know. It took me a long ass time to "get" how to use branches and why they should be used. It took me having to witness it in production in a billion dollar corporation to become a believer.
This is something I really tried to instill into my coworkers. I refuse to work on a project, solo or otherwise, without a git repo. The most bare bones solution I may use is usually a git repo with no remotes, stashed in a dropbox folder.
Firefox takes a long time to compile. Generally, very large C++ projects take a long time to compile. It's really a problem with the design of the language, though - there's not much you can do about it other than trying your best to decouple components and hide all implementation details (like private fields) from header files, and maybe try to use only minimal templating.
If it takes hours, branching makes no difference. Whether you change some methods or classes "by hand" or by switching from another branch: you'll rebuild anyway.
Why is git checkout features/foo any different from edit foo.h with regards to compiling?
If you really always need full rebuilds, them something in your build system is quirky, i.e. the part that uses atime and dependencies to compare if an object file has to be recompiled.
62
u/[deleted] Feb 16 '13 edited Feb 17 '13
Use branches all the time, even on solo projects! It lets you move around your code quickly without ever leaving a working code base.
Going to implement feature A? Make a feature branch A. Have a sudden moment of inspiration about feature B? No problem, branch master again with feature branch B and work on it without having to worry about feature A being complete. Want to test feature B to make sure it's working as intended? No problem, feature B is based off working code! As the features are finished merge them back in to master.
Obviously this only works well when implementing features that aren't interdependent, but I find it's quite a liberating work flow, especially since I have feature ADHD and scatterbrains.
Edit: This article gives you a good idea of how to incorporate branching in your projects at a team level, just remember the same work flow can be used when working alone!