Git diff untracked file vs tracked file in another branch / path

I have the following script:

  • The current branch feature/dashboard.

  • I have a raw file, tmp/dashboard_bulk.js(appeared from my browser)

  • I would like to compare it with a tracked file app/assets/javascripts/audience/dashboard_bulk.jsthat is on a branch master(again, not my current branch).

Thus, the source file is not tracked, and the target file is on a different path in another branch.

Is there any way to do this?

+4
source share
1 answer

git diffdoesn't seem to mind if you give it a path that is not being tracked.

Syntax for specifying a file in another branch branch:path/to/file.

, diff -

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

Source: https://habr.com/ru/post/1547445/


All Articles