EN
Git - print local changes in specific file (print changed lines)
5
points
In this short article, we would like to show how to print changes only for the indicated file in Git.
Quick solution:
git diff path/to/changed/file
Hint: use
git status
to see changed paths under command line.
Practical example
Let's suppose we have updated our project getting the following report using git status
:
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: common/config.sh
modified: run-application.sh
modified: ui/package-lock.json
Untracked files:
(use "git add <file>..." to include in what will be committed)
libs/
no changes added to commit (use "git add" and/or "git commit -a")
Let's suppose we want to check changes in ui/package-lock.json
file:
$ git diff ui/package-lock.json
Example output:
As we can see there are only some changes related to dependencies update.