Use a separate branch for prototype code (version control tip)

For everything you need to know about version control, check out Version control – Everything you need to know, on Programming Duck.

Sometimes you may want to try some "prototype code" that you may end up discarding. In this case, consider creating a separate branch for it.

Without a separate branch, it may be more difficult to work with your normal branch if it has the prototype code commits mixed in with the normal commits. As you work, you may lose track of which commits are the prototype ones and which are the normal ones. Then, when you want to delete the prototype code, you’ll first have to hunt for them in the commit history. In the worst case, you might accidentally delete the wrong commits or miss some of the prototype commits.

However, if you create a separate branch, you won’t have any of those problems. When you’re done, you can just delete the branch. You can also easily add the "real" commits to your prototype branch by rebasing or cherry-picking.

Final notes

That’s it for this article.

If you have any feedback, or even counter-arguments, please let me know in the comments.

Next, if you want to know more about version control, please see the article Version control – Everything you need to know.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments