Q:

Compare two Git branches without cloning

With Git CLI can we compare two git branches without cloning anyone of them? (same repo)
e.g.
branches:

master
test_branch1
test_branch2

I want a command with the help of which I can compare something like:
git diff test_branch1 test_branch2

A:

You don't clone branches, you clone the repository itself. If you want to compare remote branches, you can do:
git fetch
git diff origin/branch_1 origin/branch_2

If you don't want to get the files from the repo, you can do the following:
mkdir example
git init
git remote add origin <remote URL>
git fetch
git diff origin/branch_1 origin/branch_2

