Git Worktree: Work on Two Git Branches at the Same Time

Switching across branches can sometimes become annoying, especially if you’re currently working on different fixes or features or similar features that require you to keep continually changing branches for reference.

Of course, you could clone the repo somewhere else and maintain these two copies, but there’s also an integrated approach available since Git 2.5+: git-worktree.

This command allows you to checkout different branches on different working trees attached to the main repository.

Add a new worktree

git worktree add ../new-worktree-dir existing-branch

This command will create a new worktree on the specified directory checking out the instructed branch.

Remove a worktree

git worktree remove ../new-worktree-dir

When you finish with a worktree, you can remove it with this command. If you delete the worktree using the filesystem without using the remove option, it’s associated administrative files will eventually be removed automatically.

.NET Unit Tests – Getting Started

If you don’t like unit testing your product, most likely your customers won’t like to test it, either.

A unit test is intended to perform testing for a single method of your code, these methods should be atomic, this means that they should only perform one operation and have a single responsibility. Atomicity help us improve our testing, makes our code more reusable and easier to maintain.

Unit tests don’t care about dependencies and infrastructure, because of this, unit tests should run very quickly, this allows us to integrate unit tests into our continuous integration processes and deployments to discover bugs early on our development process.

All of this is great right? I don’t want to extend this post talking all about the perks of unit testing since most probably you are already aware of unit testing importance and want to get started right away.

Recently I came across a few series of videos from Visual Studio about getting started with unit testing for .NET and I think they’re a useful guide to enter the world of unit testing.

Unit Testing: Test Driven and Scenario Based Testing

Unit Testing: xUnit

Unit Testing: MOQ Framework

Unit Testing: Existing Code

Posted in Dev