-1

I am trying to compare files in local branch that could change or be created.

Currently I have a repository called "develop" that gets a new folder locally with contents:

./dist/index.js
./dist/index.js.map
...

The file is built and placed in dist. In remote I do not have this file, nor this folder.

Comparing with (ran in develop branch locally):

git diff origin/develop

The command above finds no changes at all unless I commit these files locally, which I am trying to avoid.

Is there any way to achieve what I am looking for?

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Telion
  • 727
  • 2
  • 10
  • 22
  • 2
    There is no reason to avoid making a local commit. Why are you reluctant to commit your changes? – William Pursell Jun 07 '22 at 15:35
  • @WilliamPursell There is also no reason *to* make a local commit if you don't intend to track the files. It's unnecessary extra work to commit files and later revert the commit just to `git diff` against something. – user229044 Jun 07 '22 at 15:36
  • @mkrieger1 this does not answer my question. I have seen this question in the past and the approach there confuses me even more than making a local commit. Basically this question is made because of confusion arise from that thread and one another also on SO. – Telion Jun 07 '22 at 18:47
  • Does this mean that running `git add -N dist` and then `git diff` does not do what you want? You said "unless I commit these files locally, which I am trying to avoid" - so yes, you can avoid it by using `git add -N` (and not making a commit). – mkrieger1 Jun 07 '22 at 19:00
  • There's no such thing as an "uncommitted branch" in Git. (The word *branch* is ambiguous, but none of its meanings correlate with files that aren't committed.) In general, though, Git is the wrong tool to deal with untracked files. Probably there should be something in Git for this, but there isn't. (Note that `git add -N` makes these into tracked files, which means Git can begin to deal with them.) – torek Jun 07 '22 at 20:07

1 Answers1

0

You don't diff against the remote branch to figure out what uncomitted changes have have happened locally. You just run git diff or git status to compare the changes in the working directory against the last commit on your current branch.

user229044
  • 232,980
  • 40
  • 330
  • 338
  • Got you, but it still is ignoring the whole dist folder when I compare – Telion Jun 07 '22 at 15:33
  • @Telion What does "ignoring" mean? Is the directory literally ignored (ie, by an entry in `.gitignore`) or are you expecting Git to tell you about the contents of an untracked directory (which Git will not do)? – user229044 Jun 07 '22 at 15:35
  • No, sorry for being unclear. I meant `git diff` literally finds no changes to the `dist/index.js` while it finds any changes to other files, that already exist in the remote repository. And it is not ignored by .gitignore. – Telion Jun 07 '22 at 15:38