GIT diffIf git status command is not enough for you and you want to find out what content of the files has been changed then you can do that using git diff
git diff command compares the committed files with the files that are not yet added to the staging area, if you want to compare the committed files with the staging area you need to run the command git diff command with —staged attribute, example below
Now can check what you have staged so for using the command git diff –cached
git diff --cached
There exist many different GUI tools under which you can view the GUI differences, run the below command to see the list of tools available and list of tools installed on your system.
Note : Some of these GIT diff tools are commercial product
git difftool --tool-help
We are going to use Meld tool as a git diff tool, for windows you can directly download the exe from their website, for ubuntu users you can run the below command
sudo apt-get install meld
Below commands can be used to set up meld tool on GIT as difftool and merge tool
git config --global diff.tool meld
git config --global difftool.meld.path "/usr/bin/meld"
git config --global difftool.prompt false
git config --global difftool.meld.cmd meld "$LOCAL" "$REMOTE"
git config --global merge.tool meld
git config --global mergetool.meld.path "/usr/bin/meld"
git config --global mergetool.prompt false
#confirm the path of meld using command : which meld
Now you can compare the unstaged and commited data using the meld difftool using below command:
git difftool --staged #to Compare the staged data and the committed data
git difftool in exactly the same way as you use
git diff. e.g.
git difftool <COMMIT_HASH> file_name
git difftool <BRANCH_NAME> file_name
git difftool <COMMIT_HASH_1> <COMMIT_HASH_2> file_name