Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Introduction to Git First Commits Viewing Changes to a File

When I enter git diff, I just get an empty line

When I enter git diff, I just get an empty line

4 Answers

Bethany Cooksey
Bethany Cooksey
14,242 Points

Have you made any changes to your file since you last used git add or git commit on it? Because if you haven't, there's no difference for git diff to show.

Bethany Cooksey
Bethany Cooksey
14,242 Points

If you are trying to see changes to a file that's "staged", a.k.a. you just used git add on it but haven't used git commit yet, you can use git diff --staged instead.

Leah Stigale
Leah Stigale
3,349 Points

The same thing happened to me, turned out I forgot to hit ctrl + s on the html file so I didn't save any of the changes, thus no changes were found when compared to what was previously committed.

Yes, I also have modified and staged my saved file, then I've modified it again (without staging it). Both show up properly in the branch master, when I type git status. However, none of these following commands show a diff in my Linux console.

git diff
git diff --staged
git log
git log -p

Does anyone know why? (all other git commands worked properly: init, add, commit -m "msg", etc.

ooh, i found the answer: someone else posted on stack overflow:

It turned out that I just needed to set the PAGER environment variable to less (or more) programs to solve both problems.

export PAGER=less
Antonio De Rose
Antonio De Rose
20,884 Points

that does emphasise, that the code in the working directory is the same to, what is in the staging area. what are you trying to do, and what are you expecting.