Modify git config file globally
633 просмотра
3 ответа
We would like to change the git config file globally, such that new file get downloaded from git repo on every git clone. Is there a way to do so? Any user who does git clone of the project should get this customized git config file in ./git/config file instead of standard one?
Автор: Dheeraj Manthangode Источник Размещён: 22.09.2019 12:05Ответы (3)
1 плюс
I don't think it's a good idea for git-clone to do this job. It's unsafe and unreasonable to modify a local existing file or override the local config without the user's awareness or permission.
I don't know why you'd like to do so but I think you can do it through other means. For your team members, you could tell them the rules they must obey during the development. For a random user who may clone your project and contribute, you could write down the rules in README
or project introduction. Users should be allowed to do whatever they'd like to in their local repositories. But when their commits are to be merged or applied into the blessed repository, you could set up barriers to those unsatisfactory commits.
For example, if you don't want files that contain dos style line endings, you could detect them in a pre-receive
hook, prevent the push, and then respond in the error message to explain why the push has failed and suggest what to do to fix the error. Making a specific git-config can be included in the suggestion.
0 плюса
As far as I know, it's not possible to force modification in global Git config for users when they clone your repository. It would cause serious security issues.
What if you decide to modify the users "signingkey" or modify the path to an executable (mergetool, difftool, etc.) ?
Instead, you could write a script modifying the config you want to update and ask users to execute this script.
You can use the following commands to update git configs:
git config --global <key> <value> # modify global .gitconfig
git config <key> <value> # modify current repository config
Автор: Antwane
Размещён: 21.06.2017 10:22
0 плюса
I think you can create a config_symlink.sh file: It will create a symlink from your config file which has been push to git. And link that file to ./.git/config
ln -s ./config ./.git/config
Then push two files.
Good luck!!!
Автор: An Huy Размещён: 21.06.2017 10:23Вопросы из категории :
- git Как я могу отменить git reset --hard HEAD ~ 1?
- git Как настроить Git голый доступный по HTTP репозиторий на IIS
- git Как мне отменить неустановленные изменения в Git?
- git Как удалить локальные (неотслеживаемые) файлы из текущего рабочего дерева Git?
- github Как клонировать все удаленные ветки в Git?
- github Как я могу удалить коммит на GitHub?
- github Доступ к оболочке git в GitX в OS X
- github Как мне вытащить свой проект из github?
- gitlab Настройка электронной почты gitlab
- gitlab Gitlab: Проблемы с запуском Unicorn, Resque with Passenger / Nginx
- gitlab Ошибка клона проекта gitlab с https
- gitlab Пароль пользователя GitLab git
- git-commit Как изменить существующие сообщения без фиксации?
- git-commit Как мне отправить исправленный коммит в удаленный репозиторий Git?
- git-commit Как отменить 'git add' перед коммитом?
- git-config Предупреждение GIT: слишком много файлов пропускает неточное обнаружение переименования
- git-config Есть ли способ кэшировать учетные данные GitHub для отправки коммитов?
- git-config Как сказать git использовать правильную личность (имя и адрес электронной почты) для данного проекта?
- git-config Передайте аргумент команде псевдонима Git