Mei
Mei

Reputation: 243

How to compare a file on 2 different git remotes

I want to compare a file (main_controller.rb) on 2 different remotes (namely, production and staging) since I got different behavior on production and staging.

I believe the code (i.e. the file) is the same, but just wanted to be sure. But I can't figure out how to do this comparison in git.

Any help would be appreciated.

Upvotes: 3

Views: 263

Answers (1)

Lily Ballard
Lily Ballard

Reputation: 185821

Do you have both remotes set up in the same repo? I'll assume you do, and that they're called production and staging. There is a way to refer to a file in a specific commit/tree, and the syntax is treeish:path/to/file. You should be able to use this with git diff to say something like

git diff production:path/to/file staging:path/to/file

Upvotes: 5

Related Questions