Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.4k points)

I've noticed that while working on one or two tickets, if I step away, I'm not sure what I worked on, what changed, etcetera.

Is there a way to see the changes made for a given file before git add and then git commit?

1 Answer

0 votes
by (27.5k points)

In case you want to view the differences between index and working tree use the following command:  

$ git diff [filename]

Alright, this command will show the changes you haven't staged to commit

In case you want to view the differences between current commit and index use the following command: 

$ git diff --cached [filename]

This command will display whatever you're about to commit

In order to view the differences between current commit and working tree use the following command

$ git diff HEAD [filename]

Browse Categories

...