0

Under Kubuntu 18 with project at bitbucket I need to review all changes during development made to some file.

I found this How to view file history in Git? branch , but trying to check all updates of resources/js/app.js file I got errors :

user@projectpath$ git log  resources/js/app.js
fatal: ambiguous argument 'resources/js/app.js': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

user@projectpath$ git diff  resources/js/app.js
fatal: ambiguous argument 'resources/js/app.js': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

user@projectpath$ git whatchanged  resources/js/app.js
fatal: ambiguous argument 'resources/js/app.js': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

I do not see why error? Or other version of git ?

$ git --version
git version 2.17.1

Also I tried to run command :

gitk --follow  resources/js/app.js

But invalid argument errors... Which way is valid ? Thanks!

mstdmstd
  • 2,195
  • 17
  • 63
  • 140
  • 2
    Is this file actually committed? What does `git status` say? Is there a `*.js` in the `.gitignore`? – Fantastic Mr Fox Mar 07 '21 at 06:14
  • 2
    I hope you understand that all of the commands you're trying have the same issue...they don't recognize `resources/js/app.js`. This isn't a git version thing. The behavior of git in this case will likely not have changed over time. It seems pretty clear that the file `resources/js/app.js` isn't under Git version control. Does the file exist (try `ls resources/js/app.js`)? As @FantasticMrFox says, do `git status`, or even better, `git status --ignored`. The latter will show you even files that are normally ignored by git due to being matched by one of your `.gitignore` files. – CryptoFool Mar 07 '21 at 06:23
  • 2
    ... if `git status --ignored` shows that file, or either the `js` or `resource` subdirectories, then that file isn't currently under git's control. – CryptoFool Mar 07 '21 at 06:24

1 Answers1

1

Git told you:

Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

That is:

git log -- resources/js/app.js

You will need the -- here if the file is not currently checked out. Otherwise, it's sometimes optional. Get in the habit of using it, so that you use it automatically whenever it is not optional.

torek
  • 448,244
  • 59
  • 642
  • 775