Oct 14, 2015

Removing merged git banches

If you work in a team, create many git branches and push them to the server, you may end up with many local branches that were merged and removed on the server. The following simple command will clean up your repository from local branches that track missing remote branches:

git fetch --all -p

Oct 12, 2015

Set environment variable when "cd"ing to the directory

I love automation! It saves a lot of time and helps to avoid mistakes.

When I work on projects, I sometimes need to set environment variables in the shell when I cd into a directory in the terminal. I ended up with a shell function that replaces the standard cd command. It checks if there is a .env file in the current directory and executes it on entering. When you leave the directory, if checks if the file .env_off exists and calls that. That file can contain normal shell commands, not just environment variables.

Do not forget to export variables in the .env file!

The script is here.