Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I see changes in the git index?

Tags:

git

Say I do

git add foo.txt

Now, foo's changes are in the index (I'm assuming git was already tracking that file). Now, when I do git diff, I can't see the changes in foo by doing

git diff

Are there some extra things that git diff wants before it shows me those changes?

like image 988
allyourcode Avatar asked Jul 30 '10 10:07

allyourcode


People also ask

What information is stored in git index?

The Git index is a critical data structure in Git. It serves as the “staging area” between the files you have on your filesystem and your commit history. When you run git add , the files from your working directory are hashed and stored as objects in the index, leading them to be “staged changes”.

How can I see what is added in git?

git whatchanged --diff-filter=A displays commits that added files, and the files they added, newest first. git whatchanged is a bit of an anachronism, you can use git log --diff-filter=A --stat or git log --diff-filter=A --numstat --pretty='COMMIT: %H %cd' for something more machine readable.

How do you check Committed changes?

Looking up changes for a specific commit If you have the hash for a commit, you can use the git show command to display the changes for that single commit. The output is identical to each individual commit when using git log -p .


1 Answers

  • To show unstaged changes only:
git diff
  • To show the staged/cached changes only:
git diff --cached
  • To show both cached and uncached changes, compare the whole working tree to the named commit (HEAD):
git diff HEAD
like image 192
Lajnold Avatar answered Sep 19 '22 12:09

Lajnold