![Forrest logo](/images/logo.png)
git-diff:tldr:7e095
The command git diff ${branch_1}..${branch_2} [--] ${filename}
is used to show the difference between two branches (${branch_1}
and ${branch_2}
) for a specific file (${filename}
). Here's a breakdown of the command:
-
git diff
: This is the basic command for displaying differences between different states of a Git repository. -
${branch_1}
and${branch_2}
: These are placeholders representing the names of two branches you want to compare. Replace them with the actual branch names you want to compare. For example,master
andfeature/branch-1
. -
..
: This is the range operator used to specify the range of commits or branches you want to compare. It indicates a range from${branch_1}
to${branch_2}
(inclusive). -
[--]
: This is an optional flag used to separate the range specification from the filename. It is used to prevent ambiguity in case the filename starts with a hyphen (-
). -
${filename}
: This is the name of the file you want to compare between the branches. Replace it with the actual filename you want to examine. For example,app.js
orREADME.md
.
When you run the command, Git will compare the specified file ${filename}
between the commits or branches represented by ${branch_1}
and ${branch_2}
. It will display the differences, highlighting the lines that were added, modified, or deleted in the file between the two branches.