I am trying to show changes between the origin of a certain folder and I would like it to show only the names of those that were added and modified using the following command but it is returning an error.
Command:
git diff --name-only --relative --diff-filter AM origin -- foldername/
Error:
fatal: bad revision 'origin'
Why did that suddenly happen? How can I resolve it?
Edit
using a different repo and 'origin/master' only returns different results
C:\gitprojects\samplefolder (master -> origin)
λ git diff --name-only --relative --diff-filter AM origin/master
readme.md
C:\gitprojects\samplefolder (master -> origin)
λ git diff --name-only --relative --diff-filter AM master origin/master
readme.md
C:\gitprojects\samplefolder (master -> origin)
λ git diff --name-only --relative --diff-filter AM origin
Properties/sample.properties
readme.md
Have a look at the man
page for git diff
(run man git-diff
).
In the Description section, you can identify the 4th variant for invoking git diff
as the one you are using. The man
page details its usage like this:
git diff [--options] <commit> [--] [<path>...]
This form is to view the changes you have in your working tree relative to the named <commit>. You can
use HEAD to compare it with the latest commit, or a branch name to compare with the tip of a different
branch.
In your case, you are using the String origin
as the <commit>
(or revision) you want to compare your working tree to. This cannot work, because origin
is not a revision/commit. That's what the error message is telling you.
origin
is a "remote". A remote is just a reference to another remote clone of the repository and git diff
cannot make comparisons between whole repositories, only between revisions/commits.
You can resolve this by specifying a commit you want to compare to. One example would be origin/master
, meaning to compare to the tip of the master
branch on the remote called origin
. What commit to specify exactly depends on what you are trying to find out specifically.
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