GIT - 不同存储库的不同配置

Kai*_*ugo 23 git github

我想知道如何更改命令的内容git config --list?我将从GitHub中提取/分叉存储库.我将在我的Windows,Linux和Mac工作站上配置这样的存储库.

谢谢.

小智 50

如果要设置特定于特定存储库的配置,可以使用两个选项,从命令行进行配置,或在编辑器中编辑repo的配置文件.

选项1:通过命令行配置

使用简单的命令行,cd进入你的Git库的根目录,并运行git config,无需--system--global标志,它们分别是配置您的计算机和用户的Git设置:

cd <your-repo>
git config <setting-name> <setting-value>
git config <setting-name>=<setting-value> # alternate syntax
Run Code Online (Sandbox Code Playgroud)

选项2:直接编辑配置文件

您的另一个选择是直接编辑repo配置文件.使用默认的Git克隆,它通常是.git/configrepo的根文件夹中的文件.只需在编辑器中打开该文件并开始添加设置,或使用命令行调用其编辑器git config --edit.

资源

您可以在官方Linux Kernel Git文档中git config了解有关配置Git的更多信息.特别是,您可能有兴趣看到一个示例Git配置:

# 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
Run Code Online (Sandbox Code Playgroud)

编辑

解决原始海报关于如何更改user.nameuser.email每个存储库的问题,以下是如何通过命令行执行此操作.切换到每个存储库,然后运行以下命令:

git config user.name "<name>"
git config user.email "<email>"
Run Code Online (Sandbox Code Playgroud)

由于您没有使用--system--global标志,上述命令将仅适用于终端工作目录中的任何回购.

  • 我不确定还有什么可说的,我已经给出了配置repo特定的Git配置文件所需的一切,只需编辑每个Git仓库目录中的`.git/config`文件.你试过吗?你有什么特别的问题吗?***您是否需要任何特定配置设置的帮助***?您是否想要了解Windows,Mac和Linux机器之间哪些设置应该不同***的建议? (2认同)