I don’t think so (the timestamp has been changed as indicated in " GIT: adding local changes to an inactive branch ).
The easiest way is to configure your IDE to automatically update.
For example, for Eclipse, this will be the Update On Access setting.
Another approach would be to keep another local repo (one where there is no local modification, so there is no need to get stuck).
Your pre-commit hook remains in your current repo.
Your hook will use your current index (what you added), but a different repo. To do this, you need to commit using:
git commit --work-tree=/path/to/other/local/repo -m "my commit message"
If the hook does not work, you may have a hook after committing (still in your current repo), go to another repo and pull the current branch, updating its (untouched) working tree.
cd /path/to/other/local/repo git --work-tree=/path/to/other/local/repo --git-dir=/path/to/other/local/repo/.git pull
(Note that your hook, which lives in your first repo, must specify the work-tree and git-dir second repo to work correctly).
This is a simplified proposal, since it does not take into account the current industry you are working on (it involves only one "master" branch).
But you can detect the branch and adapt the hook from there (with the correct check and switch to the correct branch).
After the second update of your working tree (using the post-commit binding of the first repo), this second repo is ready to serve as an untouched working tree against which your pre-commit hook (your first and current repo) is running can work safely.
source share