0

Everytime time I run npm install in the git repository I am working on, the package.json file is considered modified by git and staged for commit even if the content given by git diff are identical.

After running npm install the modify time of package.json get updated though.

enter image description here

Eturcim
  • 798
  • 8
  • 26
  • If it's staged for commit you have to use `git diff --cached` – Josh Lee Feb 22 '18 at 21:06
  • I don't understand your comment @JoshLee. I don't want package.json to be staged for commit since the content are identical before and after the command. It's not clear to me why `npm install` is modifying the _changed time_ of the file neither. – Eturcim Feb 22 '18 at 21:27
  • If git considers a file to be staged for commit, then the contents are different. If the contents were identical then git would not show the file as staged for commit. – Josh Lee Feb 22 '18 at 22:00
  • To put it another way: There being a difference between the file at HEAD and the file in the staging area is _literally the definition_ of "staged for commit". So if you're wondering why npm is modifying your file, looking at _the actual changes_ is probably a good place to start. – Josh Lee Feb 22 '18 at 22:10
  • I updated the post to illustrate that contents are identical. Just the mtime of the file is different. Would git consider mtime a difference? – Eturcim Feb 22 '18 at 23:05
  • Changing file attributes like modification time isn't enough to count as a diff. The only change you might see is that Windows has changed the permissions on the file, where you might see a diff like `old mode 100755 / new mode 100644`: https://stackoverflow.com/questions/1257592/how-do-i-remove-files-saying-old-mode-100755-new-mode-100644-from-unstaged-cha – cmbuckley Feb 22 '18 at 23:06
  • https://stackoverflow.com/questions/3920650/git-diff-show-me-line-ending-changes – Josh Lee Feb 22 '18 at 23:20

0 Answers0