Skip to content

clarify git diff behavior when HEAD is omitted #1080

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
erinmgraham opened this issue Mar 27, 2025 · 2 comments
Open

clarify git diff behavior when HEAD is omitted #1080

erinmgraham opened this issue Mar 27, 2025 · 2 comments

Comments

@erinmgraham
Copy link
Contributor

Maybe related, I stumbled upon the following sentence today:

Note that HEAD is the default option for git diff, so omitting it will not change the command’s output at all (give it a try).

I found this to be very confusing, because the output is only the same if no additional files have been staged since the last commit.

_Originally posted by @fkohrt in #769

@erinmgraham
Copy link
Contributor Author

Hi @fkohrt, thank you for your contribution! I will make a new issue with your comment because the text you referenced is found in episode 05-history and issue 769 relates to episode 04-changes.

Are you able to suggest alternative text that would be less confusing?

@fkohrt
Copy link
Contributor

fkohrt commented Mar 27, 2025

Maybe as follows?

If run without arguments, git diff compares the files in your working directory with what is about to be save permanently (the staging area). git diff HEAD compares the files in your working directory with the most recently committed version instead. The real power of git diff lies in its ability to compare with previous commits.

Displaying this comparison in another diagram like the one by @astroDimitrios here might additionaly be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants