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

Relationships with regards to 'git diff' command

In Git, when the 'git diff' command is executed, it looks at the changes of a file between the working copy and the index.

If no other modifications were made to a file after sending it to the staging area, then it is the same file; there is no difference. Working copy of file = file in the staging area at this present time.

When running the 'git diff' command in GitBash, it returns the contents of a file of the most recent commit, and then shows the modifications that were made in the current working copy.

So going back to the working copy-staging area relationship with regards to the 'git diff' command, does the staging area side of things refer to the staging area of the last commit?

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,428 Points

Consider three areas: the working tree, the index (aka staging or cached) tree, and the previous commits.

The default is to compact the working tree to the index tree. But command switches can be used to compare any combination:

  • working tree to index tree
  • working tree to commit
  • index tree to commit
  • commit to commit

See git diff for more details.