Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
git precommit 钩子如何判断git commit它前面的命令是否带有-a/--all选项?
git commit
-a
--all
如果没有-a钩子,则应仅检查分阶段的更改。
但如果它与-a它应该检查所有已知的文件。
在任何情况下都只需检查分阶段的更改。当该钩子运行时,它将看到所有要提交的更改都已暂存。这包括因为commit --all正在使用而包含的更改。因此,这将在任何一种情况下都给出正确的行为,而无需做任何特别的事情。
commit --all