How do I set default aliases or other configuration for my git repository?

前端 未结 2 589
眼角桃花
眼角桃花 2021-01-24 23:02

I\'d like to set some default aliases and other configuration for a git repository, so that when new users clone it they have those aliases immediately available for them in tha

2条回答
  •  一整个雨季
    2021-01-24 23:49

    You can not do that directly. Some of the configs, like the tools, are very platform dependent (sometimes user dependent), and git tries to avoid making that a problem for everyone using your repository.

    For example, you certainly would not want to allow someone to set a default non-local username and email for the whole repo, or to end up with a bunch of Linux-only merge tools on a Windows checkout.

    That being said, there is nothing stopping you from putting in a script with whatever commands you want in the root directory of your project and asking users to run it when they first clone. This is relatively little overhead when you are already cloning the project manually. For example, to set up your alias, do something like this in your script:

    git config --local alias.st status
    

    This has the additional advantage of letting you write different scripts for different platforms.

提交回复
热议问题