I am quite new to Git, thus maybe I am missing something here.
dan@one:/var/www/$ git status -s M GoogleChromeExtension.js M ApiClient.js
So clearly 2 files have been changed.
But when I run:
git diff
no output is shown. I was expecting to get the changes between my working copy and the latest commit.
I am sure yesterday everything was working as expecting...
Is it maybe because I haven't been pushing the changes to the remote server?
P.S.: I am using GitHub
Thanks,
Dan
Your file is already staged to be committed. You can show it's diff using the --cached option of git. To unstage it, just do what git status suggests in it's output ;) You can check The Git Index For more info.
You can run the git diff HEAD command to compare the both staged and unstaged changes with your last commit. You can also run the git diff <branch_name1> <branch_name2> command to compare the changes from the first branch with changes from the second branch. Order does matter when you're comparing branches.
Remove every file from Git's index. git rm --cached -r .
To determine whether a file has changed, Git compares its current stats with those cached in the index. If they match, then Git can skip reading the file again.
Do a git diff --cached
- it compares the HEAD and index, ie stuff added for commit.
Just a git diff
is between index and working directory, so if all the changes have been staged for commit, you won' see anything in git diff
The third form is git diff <commit>
which compares working directory and commit. So doing git diff HEAD
will also give you the diff that you want as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With