简体   繁体   English

git commit 后 Visual Studio 社区运行命令

[英]Visual Studio Community Run command after git commit

every time I do a git commit I want to catch the repo log to a file, I want to publish the commit log to my website (internal page).每次执行 git commit 时,我都想将 repo 日志捕获到文件中,我想将提交日志发布到我的网站(内部页面)。

The git command is git 命令是

git log --since='01-01-2019' > "$(ProjectDir)\Content\CurrentCommit.txt"

Because I don't know how to execute it after commit what I'm doing is to execute it at after build but I don't like it because it takes time and delays the program execution (and it isn't necessary to do it every time)因为我不知道如何在提交后执行它我正在做的是在构建后执行它但我不喜欢它因为它需要时间并延迟程序执行(并且没有必要这样做每次)

在此处输入图片说明

Any Idea?任何的想法?

Look at post-commit git hook .看看post-commit git hook This is intended to be used for notification about commit.这旨在用于有关提交的通知。 Hooks are located under the .git/hooks folder in your repo钩子位于你的.git/hooks文件夹下

You can use a git hook (specifically in this case, a post-commit hook) to run your command.您可以使用git 钩子(特别是在这种情况下,一个提交后钩子)来运行您的命令。 Place your command in the file .git/hooks/post-commit :将您的命令放在文件.git/hooks/post-commit

#!/bin/sh
git log --since='01-01-2019' > "Content/CurrentCommit.txt"

You might need to adjust the directory of the file.您可能需要调整文件的目录。 The working directory of the git hook will be your repository root. git hook 的工作目录将是您的存储库根目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM