github仓库作为git模板目录

github仓库作为git模板目录

本文介绍了github仓库作为git模板目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,可以通过git init --template=<template_dir>git clone <repository> --template=<template_dir>初始化或克隆git存储库,这些存储库仅复制.git文件夹中给定文件夹中的所有内容,这对于钩子等很有用. /p>

所以我想知道,是否有可能提供github存储库作为template_dir?这样做的原因是,我想为多个项目/团队成员设置git钩子,以使其尽可能自动和面向未来.我现在做的方式是在rep中有一个git_hooks文件夹并手动将其符号链接,但是我正在寻找一种方法来删除该额外的步骤并使它更多地自动化.

解决方案

我只是在公司设置了git-template存储库.到目前为止,它在hooks目录中只有一个prepare-commit-msg钩子,它在分支名称(在本例中为跟踪器编号)前添加了提交消息的权限.常见的工作流程是先克隆git-template存储库,或提取任何最近的更改,然后使用--template选项进行git init重新初始化每个开发人员的本地存储库.到目前为止,它已经广受欢迎.

So to my understanding there is the possibility to initialize or clone a git repository via git init --template=<template_dir> or git clone <repository> --template=<template_dir>, which just copies everything in that given folder in the .git folder, which is useful for hooks, etc.

So I was wondering, is there any possibility to provide a github repository as the template_dir? The reason for that is, I want to set up git hooks for a multiple projects/team members as automatic and future proof as possible. The way I am doing it right now is having a git_hooks folder in the rep and symlink it manually, but i am looking for a way to remove that extra step and automate it a bit more.

解决方案

I just setup a git-template repository at my company. So far it just has a single prepare-commit-msg hook in the hooks directory which prepends branch names (tracker numbers in our case) to commit messages. The common workflow would be to first clone the git-template repo, or pull any recent changes, and then use the --template option to git init to re-initialize each developer's local repositories. So far it's been well received.

这篇关于github仓库作为git模板目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 20:07