Monday, 26 January 2026

Git: Cleaning up

Sometimes, our IDE can make a mess of things (mostly because we did something wrong, though).

And in order to fix it, sometimes we have to get rid of all unversioned files, so that we have a clean git repository and then create a new Project in our IDE.

This helps as it forces the IDE to recreate its config files from scratch.

This blog is just a small note on how to clean your git repository of all unversioned files.

A dry run would look like this:

git clean -n -x -d

A proper clean would look like this:

git clean -d -x

Options:

-n
dry run
-d
also recursively delete unversioned directories.
-x
ignore .git-ignore rules (convenient for cleaning up buildproducts and IDE config files)

Output of a dry run would look something like this:

% git clean -n -x -d
Would remove .DS_Store
Would remove .idea/
Would remove mrbear-parent/mrbear-app/target/
Would remove mrbear-stubs/.gradle/
Would remove mrbear-stubs/.kotlin/
Would remove mrbear-stubs/build/

See also "git restore" or "git reset".

References

git-clean - Remove untracked files from the working tree
https://git-scm.com/docs/git-clean

Thursday, 15 January 2026

Kotlin : NullSafety + Defaults

So, I had a discussion with my colleague about null safety and how it can be non-intuitive if you're not yet used to it.

So we had the following code:

In a lot of REST applications, an Exception may be thrown when a resource does not exist. But it's important to differentiate between "no resource" and "oh no! An exception occurred! We're in trouble!".

That's what this example code does.

So, what did the "getStatus" method do exactly?

This causes the test to fail.

The code should have been "?: false", but doing that does look weird.

A clearer solution would be:

The problem with Kotlin might be that there's alot of "?." and "?:" and "!!" and quite frankly it makes it hard to read.

What do you think?