Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+10 votes
2 views
in DevOps and Agile by (19.7k points)

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.rbfile_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)?

1 Answer

+13 votes
by (62.9k points)

Use a command like:

git diff file_2.rb

See the git diff documentation for full info on the types of things you can get differences for.

Normally, git diff by itself shows all the changes within the whole repository (not simply the present directory).

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...