Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
222 views
in Technique[技术] by (71.8m points)

Is there a way with to prevent "git stash pop" from marking files as modified?

I implemented a git-hook to scan my commits through pyflakes and jshint, and after reading Yipit's commentary on why most pre-commit hooks are broken, I chose to implement his git stash and git stash pop suggestions.

Unfortunately, git stash pop marks the files as 'modified', which then causes my IDE to warn me whenever I go back to that page " modified on disk. Reread from disk?" It then asks "Are you sure you want to edit this buffer?" and finally "Are you sure you want to save this buffer over a modified file?"

I appreciate everything it's trying to do for me, but it's asking me about functionally non-existent "changes".

Short of playing weird guessing games with touch is there some way to prevent git stash pop from marking all of the files it touched as changed?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Are you sure the changes are non-existant? If the file is showing as modified, something has changed, even if it's whitespace or the permission (executable state) of a file. You can use git diff to see the changes. You can also review the changes by using the git commit -av command (the -v flag will display the diff of the commit).

Your IDE is going to keep a current "buffer" state of a file. If that file changes on the disk (which git stash pop|apply will do), the IDE will recognize this and unless you have it set to automatically refresh the file (usually in your IDE settings/preferences), it may prompt you if you want to save the current buffer as a new file -- which is not typically necessary when using git -- or to re-load the buffer with the changed state of the file.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...