How do I show uncommitted changes in Git?
I STFW'ed, and these commands are not working:
teyan@TEYAN-THINK MINGW64 /d/nano/repos/PSTools/psservice (teyan/psservice) $ git status On branch teyan/psservice Your branch is up-to-date with 'origin/teyan/psservice'. Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: psservice.c modified: psservice.vcxproj.filters teyan@TEYAN-THINK MINGW64 /d/nano/repos/PSTools/psservice (teyan/psservice) $ git diff teyan@TEYAN-THINK MINGW64 /d/nano/repos/PSTools/psservice (teyan/psservice) $ git diff master fatal: ambiguous argument 'master': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]'
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.
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.
The git diff command displays the differences between files in two commits or between a commit and your current repository. You can see what text has been added to, removed from, and changed in a file. By default, the git diff command displays any uncommitted changes to your repository.
How to show uncommitted changes in Git
The command you are looking for is git diff
.
git diff
- Show changes between commits, commit and working tree, etc
Here are some of the options it expose which you can use
git diff
(no parameters)
Print out differences between your working directory and the index.
git diff --cached
:
Print out differences between the index and HEAD (current commit).
git diff HEAD
:
Print out differences between your working directory and the HEAD.
git diff --name-only
Show only names of changed files.
git diff --name-status
Show only names and status of changed files.
git diff --color-words
Word by word diff instead of line by line.
Here is a sample of the output for git diff --color-words
:
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