QuestionQ13

701.3 Source Code Management

Which of the following statements are correct about the commands git diff and git diff --staged?

Choose two
  • A git diff --staged shows changes of all commits that were not pushed to a remote repository yet.
  • B git diff shows changes that were not added to the next commit.
  • C git diff and git diff --staged always lead to the same result If a repository does not have at least one remote repository.
  • D git diff --staged shows changes that will be included in the next commit.
  • E git diff --staged shows changes included in the last successful commit of the current branch.
Explanation

git diff shows differences between the working tree and the index, which are changes not added to the next commit. git diff --staged (equivalent to git diff --cached) shows differences between the index and HEAD, which are the changes staged for inclusion in the next commit.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!