Viewing difference between files in git

git diff command can be used to view the difference between files in Git.
  • git diff : shows the difference between working directory and staging area
  • git diff –cached : shows the difference between staging area and HEAD (last commit)
  • git diff HEAD : shows the difference between working directory and HEAD (last commit)
  • git diff HEAD^1 : shows the difference between working directory and HEAD (second last commit)
  • git diff –name-only :shows only the list of files that have changed in working directory since last commit
  • gitk f1.txt : shows the difference in GUI
Below image shows how to view difference between files in Working directory, staging area and HEAD (last commit in repository).Below image shows the sample output of above commands. Lines in red color means that line is not available in source file. Lines in green color means that line is available in source file but not in destination file.
 
gitk f1.txt

Below image shows how gitk tool looks like.

Web development and Automation testing

solutions delivered!!