Git diff untracked file against a tracked file in another branch/path

diff, git

Solution

`git diff` doesn't seem to mind if you give it a path that is untracked.

The syntax for pointing to a file on a different branch is `branch:path/to/file`.

Putting these two together, the command to do the diff is

git diff \
master:app/assets/javascripts/audience/dashboard_bulk.js \
tmp/dashboard_bulk.js

Problem

I have the following scenario: Current branch is `feature/dashboard`. I have an untracked file, `tmp/dashboard_bulk.js` (came from my browser) I'd like to compare it with a tracked file `app/assets/javascripts/audience/dashboard_bulk.js` that's on branch `master` (again, not my current branch). So source file is untracked, and destination file is on a different path in a different branch. Is there a way to do this?

Original source