command-line - use shortcut "-" for previous dir (bash) or branch (git)

in «tip» by Michael Beard
Tags: , , , , ,

What is the bash shortcut to change to the previous directory?

A nice description here of how this works. Can be used in git as well.

From man page for bash:

When a is used as the operand, this shall be equivalent to the command: cd "$OLDPWD" && pwd which changes to the previous working directory and then writes its name.

It was brought up in a discussion and I tried to find it but couldn't until I asked if it was git only or bash and then was able to find th link above.

Some others of interest: