

This is to view the changes between two arbitrary. git diff -merge-base A is equivalent to git diff $(git merge-base A HEAD). If -merge-base is given, instead of using, use the merge base of and HEAD. You can use HEAD to compare it with the latest commit, or a branch name to compare with the tip of a different branch.

This form is to view the changes you have in your working tree relative to the named. git diff -cached -merge-base A is equivalent to git diff -cached $(git merge-base A HEAD).

unborn branches) and is not given, it shows all staged changes. Typically you would want comparison with the latest commit, so if you do not give, it defaults to HEAD. This form is to view the changes you staged for the next commit relative to the named. You can omit the -no-index option when running the command in a working tree controlled by Git and at least one of the paths points outside the working tree, or when running the command outside a working tree controlled by Git.

This form is to compare the given two paths on the filesystem. You can stage these changes by using git-add(1). In other words, the differences are what you could tell Git to further add to the index but you still haven’t. This form is to view the changes you made relative to the index (staging area for the next commit). Show changes between the working tree and the index or a tree, changes between the index and a tree, changes between two trees, changes resulting from a merge, changes between two blob objects, or changes between two files on disk. Compare different files from the current branch to other branch: git diff branch: path/to/file2 path/to/file.Compare a single file between two branches or commits: git diff branch_1.Output a summary of file creations, renames and mode changes since a given commit: git diff -summary commit.Show only names of changed files since a given commit: git diff -name-only commit."1 week 2 days" or an ISO date): git diff months|weeks|days|hours|seconds ago}' Show changes from all commits since a given date/time (a date expression, e.g.Show only staged (added, but not yet committed) changes: git diff -staged.Show all uncommitted changes (including staged ones): git diff HEAD.Show unstaged, uncommitted changes: git diff.Show changes between commits, commit and working tree, etc Examples (TL DR)
