Use a command like:
git diff file_2.rb
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).
Use a command like:
git diff file_2.rb
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).
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
This will show the entire history of the file (including history beyond renames and with diffs for each change).
In other words, if the file named bar was once named foo, then git log -p bar (without the --follow option) will only show the file's history up to the point where it was renamed -- it won't show the file's history when it was known as foo. Using git log --follow -p bar will show the file's entire history, including any changes to the file when it was known as foo.
What command can view who changed specific line of a file?
How can I see what has changed in a file before committing to git? - Stack Overflow
Is there a way to use 'git show' on staged changes?
Is there any tool that can show me the progression of the changes made in any file by checking all historical commits?
Videos
Hi, What command can view who changed specific line of a file? thanks
You're looking for
git diff --staged
Depending on your exact situation, there are three useful ways to use git diff:
- Show differences between index and working tree; that is, changes you haven't staged to commit:
git diff [filename]
- Show differences between current commit and index; that is, what you're about to commit (
--stageddoes exactly the same thing, use what you like):
git diff --cached [filename]
- Show differences between current commit and working tree:
git diff HEAD [filename]
git diff works recursively on directories, and if no paths are given, it shows all changes.
Use git-diff:
git diff -- yourfile