git config --global insteadOf for a project, not global

随声附和 提交于 2021-01-29 01:42:49

问题


I created a .gitconfig file using the command

git config --global url."https://".insteadOf git://

However, this will replace all git:// URLs WITH https:// ones, for all projects on my computer.

I want this functionality, for a specific project. Is it possible to configure a replace for git:// URLs for https:// URLs for a certain project/not global?

This project is shared, and I don't want everyone to go through the trouble of running the command locally.


回答1:


You can do the following:

  1. Edit .gitconfig file and just remove the [url] section.

  2. Cd into the project in which you want this instead to work.

  3. Run git config url."https://".insteadOf git://

Explaination:

git config --global is your user-wide setting, i.e it is applied to all projects in that users home dir. The config file is .gitconfig and it resides in user's homedir

git config is repository specific configuration. If adds an entry in your $GIT_DIR/config file. So it is specific to only that directory

Hope it helps!

Happy gitting!




回答2:


You can use:

git config --local

Out of your (git) project source directory to do project / repository specific configurations.


The own git documentation often helps, e.g.

git config //List of Commands & Options
git help config //the complete documentation about the config command


来源:https://stackoverflow.com/questions/25974697/git-config-global-insteadof-for-a-project-not-global

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