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 trialKristian Woods
23,414 PointsWhen 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
14,242 PointsHave 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.
Leah Stigale
3,349 PointsThe 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.
Mark Chesney
11,747 PointsYes, 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.
Mark Chesney
11,747 Pointsooh, 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
20,885 Pointsthat 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.
Bethany Cooksey
14,242 PointsBethany Cooksey
14,242 PointsIf 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 usedgit commit
yet, you can usegit diff --staged
instead.