Transcript from the "Git Show and Diffs" Lesson
>> Nina Zakharenko: Git Show, let's just look at commits and their contents. If we want to show what files are changed in the commit, we can use the stat flag. It's also helpful to look at files from another commit. It we wanted to just briefly look at a file from another commit, you can say get show commit and then colon file.
[00:00:20] A surprising amount of developers that have been using Git for a while don't know about the Git Show commands. They know that for a shared repository, they can go on GitHub to look at the commit. But it's really easy to do it from the command line too. You don't have to open a browser and click around.
[00:00:41] It's just all there. Git Show works on any reference.
>> Nina Zakharenko: And it can also show the contents of any commit that's been orphaned. For example, if we lost a commit after a rebase, or in a detached head state, we can still look at it as long as it's in our history.
>> Nina Zakharenko: Diff is a common tool that we use as developers when working on git. It shows you changes between commits and between the staging area and the repository. It can show you what's in the working area. For unstaged changes you would just do a git diff. Stage changes, get diff dash dash staged.
[00:01:27] A good way to think about it is unstaged changes are what could be in the next commit and staged changes are what will be in the next commit.
>> Nina Zakharenko: You can also pass file arguments to diff to narrow down which file you wanna look at the diff of.
[00:01:52] I saw a great explanation of diffing using Venn diagrams. And I wanted to share that with you. Note that the default syntax of diff is the same as the two dot notation. You might have seen the two dot notation on stack overflow or somewhere else. But it just means the same thing.
[00:02:13] Using a diff is going to show you between A and B, is gonna show you of the changes on branch B, but not on branch A. So this comment git diff A B will show you only the blue changes.
>> Nina Zakharenko: It is also possible to so called diff branches.
[00:02:39] We can ask, what branches are merged with master? Maybe they can be cleaned up. We can do that with a merged flag and we can also ask, which branches haven't been merged with a master yet. Maybe I was working on a feature and I forgot about it. I can use this to take a look and see which of my branches are unmerged.