Tricks for interacting with a branch, without checking it out.

Browse a directory (like ls): Syntax:

1
2
git show [ref]:[path]
git show master:your/path/

See contents of a file (command as above): Syntax:

1
2
git show [ref]:[filepath]
git show master:your/path/file.php

Checkout a specific file or directory from a different branch: Syntax:

1
2
git checkout [ref] -- [path]
git checkout master -- your/path/file.php

Note: There are other ways to do similar tasks such as git ls-tree and they may have more options. However I find these to be more accessible and easy to remember.