0
0
Gitdevops~5 mins

git diff between branches - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the command git diff branch1 branch2 do?
It shows the differences between the files in branch1 and branch2. You can see what changes exist from one branch to the other.
Click to reveal answer
beginner
How can you see only the names of files that differ between two branches?
Use git diff --name-only branch1 branch2. This lists just the file names that have changes.
Click to reveal answer
intermediate
What is the difference between git diff branch1 branch2 and git diff branch2 branch1?
The output shows changes from the first branch to the second. So switching the order reverses the direction of the diff.
Click to reveal answer
beginner
Can git diff show changes between your current working directory and a branch?
Yes. Use git diff branch_name to see changes between your current files and that branch.
Click to reveal answer
beginner
What does the --stat option do with git diff?
It shows a summary of changes with file names and how many lines were added or removed, instead of full details.
Click to reveal answer
Which command shows the detailed differences between two branches?
Agit diff branch1 branch2
Bgit status
Cgit log
Dgit checkout branch1
How do you list only the files that differ between two branches?
Agit branch --list
Bgit diff --stat branch1 branch2
Cgit diff --name-only branch1 branch2
Dgit diff --cached
What happens if you swap the branch order in git diff branch1 branch2 to git diff branch2 branch1?
ANo difference in output
BThe diff output reverses, showing changes from branch2 to branch1
CIt merges the branches
DIt deletes branch1
Which command shows a summary of changes with line counts between branches?
Agit diff --name-only branch1 branch2
Bgit log --stat
Cgit diff --cached
Dgit diff --stat branch1 branch2
Can git diff branch_name show changes between your current files and a branch?
AYes
BNo
COnly if you commit first
DOnly if branches are merged
Explain how to use git diff to compare two branches and what the output means.
Think about comparing two versions of a document to see what changed.
You got /4 concepts.
    Describe how to get a quick list of files that differ between two branches without full details.
    Imagine checking which chapters changed without reading the whole text.
    You got /4 concepts.