问题描述
我想知道我该如何更改命令 git config --list
的内容?我将从中拉取/分发存储库。我将在Windows,Linux和Mac工作站上配置这样的存储库。
谢谢。
如果您想要设置特定于特定存储库的配置,您有两种选择,可以从命令行配置它,或者在编辑器中编辑repo的配置文件。 >
选项1:通过命令行配置
只需使用命令行 cd
放入你的Git仓库的根目录,运行
git config
, 而不用 - system
和 - global
标记,分别用于配置机器和用户Git设置:
cd< your-repo>
git config< setting-name> <设定值>
git config< setting-name> =< setting-value> #备选语法
选项2:直接编辑配置文件
您的其他选项是直接编辑repo配置文件。使用默认的Git克隆,它通常是您的仓库根文件夹中的 .git / config
文件。只需在编辑器中打开该文件并开始添加设置,或者在命令行中使用 git config --edit
调用编辑器。
资源
您可以在。特别是,您可能有兴趣查看:
#核心变量
[core]
;不要相信文件模式
filemode = false
#我们的差异算法
[diff]
external = / usr / local / bin / diff-wrapper
renames = true
[branchdevel]
remote = origin
merge = refs / heads / devel
#代理设置
[core]
gitProxy = sshforkernel.org
gitProxy = default-proxy;其余的
[include]
path = /path/to/foo.inc;包括绝对路径
path = foo;展开相对于当前文件的foo
path =〜/ foo;在$ HOME目录中展开foo
编辑
解决,以下是如何通过命令线。切换到每个存储库,并运行以下命令:
git config user.name< name>
git config user.email< email>
由于您没有使用 - system
或 - global
标志,上述命令将适用于您在终端工作目录中拥有的任何回购。
I was wondering how am I going to change the contents of the command git config --list
? I am going to pull/fork a repository from GitHub. I am going to configure such repositories on both of my Windows, Linux and Mac workstations.
Thanks.
If you want to set up configurations that are specific for a particular repository, you have two options, to configure it from the command line, or edit the repo's config file in an editor.
Option 1: Configure via command line
Simply use the command line, cd
into the root of your Git repo, and run git config
, without the --system
and the --global
flags, which are for configuring your machine and user Git settings, respectively:
cd <your-repo>
git config <setting-name> <setting-value>
git config <setting-name>=<setting-value> # alternate syntax
Option 2: Edit config file directly
Your other option is to edit the repo config file directly. With a default Git clone, it's usually the .git/config
file in your repo's root folder. Just open that file in an editor and starting adding your settings, or invoke an editor for it at the command line using git config --edit
.
Resources
You can learn more about configuring Git at the official Linux Kernel Git documentation for git config
. In particular, you may be interested in seeing an example Git config:
# Core variables
[core]
; Don't trust file modes
filemode = false
# Our diff algorithm
[diff]
external = /usr/local/bin/diff-wrapper
renames = true
[branch "devel"]
remote = origin
merge = refs/heads/devel
# Proxy settings
[core]
gitProxy="ssh" for "kernel.org"
gitProxy=default-proxy ; for the rest
[include]
path = /path/to/foo.inc ; include by absolute path
path = foo ; expand "foo" relative to the current file
path = ~/foo ; expand "foo" in your $HOME directory
Edit
Addressing the original poster's question about how to change user.name
and user.email
per repository, here is how to do it via the command line. Switch to each repository, and run the following:
git config user.name "<name>"
git config user.email "<email>"
Since you're not using the --system
or the --global
flags, the above commands will apply to whichever repo you have in your terminal working directory only.
这篇关于GIT - 针对不同存储库的不同配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!