What git branch should I commit unit tests to?

I’m currently following the ever-popular git workflow described here.

One thing it doesn’t discuss is how to handle unit testing. Let’s say I write some code and commit to develop. I want to write a test for it, but I don’t want it in my develop history, I’d like to keep the tests separate so that when I look at git log I only see changes to the main code. However, if I commit the test to a separate test branch, I’ll have to merge develop/test back and forth constantly, resulting in a ridiculous amount of merge commit clutter.

How do you manage unit testing in a git repository?

  • git workflow for staging deployment with multiple feature branches (aka. easy branch replace)
  • How to setup github repository in my NetBeans IDE?
  • Git log output to XML, JSON, or YAML?
  • How and/or why is merging in Git better than in SVN?
  • How do I determine what files in my ClearCase local view have not yet been added to source control?
  • What is going wrong in my git svn workflow?
  • Why does git checkout create a branch which tracks a remote branch?
  • Git missed rebase for extended branch development?
  • One Solution collect form web for “What git branch should I commit unit tests to?”

    Unit tests are part of your source tree: They evolve as your code evolves, and feature branches have their own unit tests that evolve as the features evolve. There’s no reason to keep them in a separate branch.

    Note that git log accepts a path parameter, so if you want to avoid seeing test-only log entries, you can do the filtering at that point. I typically keep my src and testsrc source folders separate and adjacent, so I can see changes to one or the other easily just by specifying git log src or git log testsrc.

    Git Baby is a git and github fan, let's start git clone.