How share a config file in git?

怎甘沉沦 提交于 2019-12-10 01:45:02

问题


I have editor settings that I want to spread in all repositories. If the user defines its own settings, it should erase the repository choices of course.

I want to do that because I have a class and every student clone the repo. Usually they forget to set the core.editor setting and ends up messing around with vi, usually crashing the repo just like if they have cursed magical power.

As it worked for my HOME dir, I tried to use a .gitconfig in my repo dir, like I would set a .gitignore, but it doesn't seem to work.

EDIT :

  • --global DOES let the user set its preference to override the repo, but it DOES'T allow him to fetch the repos config while cloning it.
  • .git/config is not shared among cloned repo

回答1:


Distribute your repo using rsync or tar/untar, rather than using "git clone", which as you have seen, does not copy repo-special files.




回答2:


I do this by moving the config file up to the working dir to get it versioned.

Then you could ask the other person to make a link to the config:

$ rm .git/config
$ cd .git
$ ln -s ../config config

You could then write this in a script or in one line to let them copy and paste.




回答3:


You could create a shell script in the repo that sets these values through git config. That would allow the students to see how they do it themselves, and it gives them a way to undo their local settings.

Unfortunately, this wouldn't be automatic.

Example:

#! /bin/sh
git config core.editor "ed"



回答4:


Global settings can be set via: git config --global

Maybe you should first let the students clone the configuration file (from its own repository) to their home directories.



来源:https://stackoverflow.com/questions/2246465/how-share-a-config-file-in-git

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