eddiemoya

Interact With a Branch, Without Checking it Out.

Tricks for interacting with a branch, without checking it out. Browse a directory, or view the contents of files.

Browse a directory (like ls):

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

See contents of a file (command as above):

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

Checkout a specific file or directory from a different branch:

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

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.