It can be helpful to see the changes between two sets of code; git diff
lets us do this by comparing two Git references and outputting the differences between them. In this lesson, we show how to use git diff
along with the --stat
, --cached
, HEAD
, origin/master
, file(s)/dir(s)
options.
If you want to see the difference between stagin area with last commit:
git diff --cached
See the all umcommit changes:
git diff HEAD
See the different with branch:
git diff origin/master //will show all the change which in local but not in remote master
Compare the file with remote branch:
git diff origin/master getRandomNumber.js // show the difference between local getRandomNumber.js file with remote master branch