Is there a hook on git for post-reset?

拥有回忆 提交于 2019-12-22 09:18:17

问题


I have some local files that all developers have to change. I marked the files as "assume unchanged" but that doesn't keep them from changing when doing a reset. Is there a hook on git that's executed after git reset?

If not, does anybody have a suggestion on how to handle this situation?


回答1:


You can find a list of Git hooks here:

  • applypatch-msg
  • pre-applypatch
  • post-applypatch
  • pre-commit
  • prepare-commit-msg
  • commit-msg
  • post-commit
  • pre-rebase
  • post-checkout
  • post-merge
  • pre-receive
  • update
  • post-receive
  • post-update
  • pre-auto-gc
  • post-rewrite

There is no post-reset hook among them.




回答2:


In case it help, post-checkout seems to be triggered after a reset.

The 3rd param of that trigger would probably allow you to do what you want.

E.g.:

#!/bin/sh


if [ "$3" -eq "0" ]
then
    echo "$3 indicates whether the checkout was a branch checkout (changing branches, flag=1) or a file checkout (retrieving a file from the index, flag=0)"
fi


来源:https://stackoverflow.com/questions/18645512/is-there-a-hook-on-git-for-post-reset

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!