I know that I can use the git diff
command to check the changes, but, as far as I understood, it is directory based. This means it gives all the changes of all files on the current directory.
How can I check only the changes in one specific file? Say, I have changed files file_1.rb
, file_2.rb
, ..., file_N.rb
, but I am only interested in the changes in the file file_2.rb
. How do I check these changes then (before I commit)?
you can also try
For commits, git show will show the log message and textual diff (between your file and the commited version of the file).
You can check git show Documentation for more info.
Use a command like:
See the
git diff
documentation for full information on the kinds of things you can get differences for.Normally,
git diff
by itself shows all the changes in the whole repository (not just the current directory).You can use below command to see who have changed what in a file.
git blame <filename>
Another method (mentioned in this SO answer) will keep the history in the terminal and give you a very deep track record of the file itself:
git log --follow -p -- file
to list only commits details for specific file changes,
to list difference among various commits for same file,
to list only commit and its message,
Or if you prefer to use your own gui tool:
You can set your gui tool guided by this post: How do I view 'git diff' output with a visual diff program?