Git配置文件:最佳做法 [英] Git config files: Best practice

查看:151
本文介绍了Git配置文件:最佳做法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设法让Git和Github一起运行,现在(一年后)我想教导团队他们如何做到这一点。我从



编辑@代码学徒

从git-bash

  $ git config --list --show-origin --system 
file:C:\\Git\\\\\\\\\\\\\\\\\\\\\\\\\\\'

和cmd

  C:\07 Rprogress \ 11 Rettung ZCH> git config --list --show-origin --system 
file:C:\\Git \\ credential.helper =经理



文件:C:\\ Program Data / Git / configcore.autocrlf = true
file:C :\\ProgramData/Git/configcore.fscache = true
file:C:\\ Program Data / Git / configcolor.diff = auto
file:C:\\ \\\ProgramData/Git/configcolor.status = auto
file:C:\\ Program Data / Git / configcolor.branch = auto
file:C:\\\ \\ ProgramData / Git / configcolor.interactive = true
file:C:\\ Program Data / Git / confighelp.format = html
file:C:\\ProgramData / Git / confighttp.sslcainfo = C:/Git/mingw64/ssl/certs/ca-bundle.crt
文件:C:\\ProgramData/Git/configdiff.astextplain.textconv = astextplain
file:C:\\ProgramData / Git / configrebase.autosquash = true

file:C:\\Git\\\ mingw64 / etc / gitconfigcredential.helper = manager#...查看文件:C:/Users/myname/.gitconfig

文件:C:/Users/myname/.gitconfig filter.lfs。 clean = git-lfs clean%f
file:C:/Users/myname/.gitconfig filter.lfs.smudge = git-lfs smudge%f
file:C:/Users/myname/.gitconfig filter.lfs.required = true
文件:C:/Users/myname/.gitconfig user.name =我的名字
文件:C:/Users/myname/.gitconfig user.email = my.name @ domain.com
文件:C:/Users/myname/.gitconfig credential.helper = wincred
文件:C:/Users/myname/.gitconfig alias.hist = log --pretty = format: '%h - %an,%ad:%s'--graph --date = short
file:C:/Users/myname/.gitconfig difftool.kdiff3.cmd ='C:/ Program Files / KDiff3 / kdiff3'$ LOCAL $ REMOTE
file:C:/Users/myname/.gitconfig difftool.kdiff3.keepbackup = false
file:C:/Users/myname/.gitconfig difftool.kdiff3.trustexitcode = false
file:C:/Users/myname/.gitconfig merge.conflictstyle = diff3

file:.git / config core.reposito ryformatversion = 0
file:.git / config core.filemode = false
file:.git / config core.bare = false
file:.git / config core.logallrefupdates = true
文件:.git / config core.symlinks = false
文件:.git / config core.ignorecase = true
文件:.git / config core.hidedotfiles = dotGitOnly
文件:. git / config remote.origin.url = https://github.com/repo/Rettung-ZCH
file:.git / config remote.origin.fetch = + refs / heads / *:refs / remotes / origin / *
file:.git / config branch.master.remote = origin
file:.git / config branch.master.merge = refs / heads / master
file:.git / config branch.dev1.remote = origin
file:.git / config branch.dev1.merge = refs / heads / dev1
file:.git / config branch.dev2.remote = origin
file :.git / config branch.dev2.merge = refs / heads / dev2


解决方案 div>



  • 是否有最佳做法,哪些参数sho uld显示在哪个配置文件中?


这完全取决于您,无论您想要仅在一个存储库上,在您使用用户帐户访问的所有存储库或本机上的所有存储库上进行设置(当然,每次当然,只有在不会从较低配置级别覆盖)。



  • 我标记了可以通过--system,--global和--local访问的部分。是否有人知道第一部分属于哪里?


据我记得这些是默认Git for Windows客户端的值,并在系统设置级别上(或高于)。您可以使用 git config --file c:\ Program Data \Git\config --list 等来列出并更改它们。



  • 绿色就是一切,我认为它是可以的(我知之甚少)。

正如我所说,完全取决于您。当地的绿色设置很可能只在当地有用,是的。例如,我的工作箱上没有在全球范围内设置 user.email ,因为我在私人和公司回购处使用不同的地址。通过不在全局级别配置,我在本地级别上提醒它在进行第一次提交时进行设置。


$ b



  • 红色很奇怪,因为它存在两次

您可以在每个级别上设置每个设置,上层的覆盖水平值,这是完全合法的。你可以e。 G。为系统上的所有用户设置为使用 credential.helper = manager ,但为您的用户使用 credential.helper = wincred 像你在你的例子中。


I managed somehow to make Git running with Github and now (a year later) I would like to teach the group how they can do the same. I learned quite a lot from here, but even with the answer, some things remain unclear. Please apologize, if I didn't got it from the git reference

Questions:

  • Is there a best practice, which parameters should show up in which config file?

... Continued from my example below:

  • I marked the parts which I can access via --system, --global and --local. Does anybody know where the first part belongs to?
  • Green is everything, where I think, it is ok (with my very limited knowledge).
  • Red is strange as it exists twice

When I run git config --list --show-origin I get the following result:

Edit @Code-Apprentice:
From git-bash

$ git config --list --show-origin --system
file:"C:\\Git\\mingw64/etc/gitconfig"   credential.helper=manager

and cmd

C:\07 Rprogress\11 Rettung ZCH>git config --list --show-origin --system
file:"C:\\Git\\mingw64/etc/gitconfig"   credential.helper=manager

Git output as code:

file:"C:\\ProgramData/Git/config"       core.symlinks=false # ... see .git/config 
file:"C:\\ProgramData/Git/config"       core.autocrlf=true
file:"C:\\ProgramData/Git/config"       core.fscache=true
file:"C:\\ProgramData/Git/config"       color.diff=auto
file:"C:\\ProgramData/Git/config"       color.status=auto
file:"C:\\ProgramData/Git/config"       color.branch=auto
file:"C:\\ProgramData/Git/config"       color.interactive=true
file:"C:\\ProgramData/Git/config"       help.format=html
file:"C:\\ProgramData/Git/config"       http.sslcainfo=C:/Git/mingw64/ssl/certs/ca-bundle.crt
file:"C:\\ProgramData/Git/config"       diff.astextplain.textconv=astextplain
file:"C:\\ProgramData/Git/config"       rebase.autosquash=true

file:"C:\\Git\\mingw64/etc/gitconfig"   credential.helper=manager # ... see file:C:/Users/myname/.gitconfig

file:C:/Users/myname/.gitconfig    filter.lfs.clean=git-lfs clean %f
file:C:/Users/myname/.gitconfig    filter.lfs.smudge=git-lfs smudge %f
file:C:/Users/myname/.gitconfig    filter.lfs.required=true
file:C:/Users/myname/.gitconfig    user.name=My name
file:C:/Users/myname/.gitconfig    user.email=my.name@domain.com
file:C:/Users/myname/.gitconfig    credential.helper=wincred
file:C:/Users/myname/.gitconfig    alias.hist=log --pretty=format:'%h - %an, %ad: %s' --graph --date=short
file:C:/Users/myname/.gitconfig    difftool.kdiff3.cmd='C:/Program Files/KDiff3/kdiff3' $LOCAL $REMOTE
file:C:/Users/myname/.gitconfig    difftool.kdiff3.keepbackup=false
file:C:/Users/myname/.gitconfig    difftool.kdiff3.trustexitcode=false
file:C:/Users/myname/.gitconfig    merge.conflictstyle=diff3

file:.git/config        core.repositoryformatversion=0
file:.git/config        core.filemode=false
file:.git/config        core.bare=false
file:.git/config        core.logallrefupdates=true
file:.git/config        core.symlinks=false
file:.git/config        core.ignorecase=true
file:.git/config        core.hidedotfiles=dotGitOnly
file:.git/config        remote.origin.url=https://github.com/repo/Rettung-ZCH
file:.git/config        remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
file:.git/config        branch.master.remote=origin
file:.git/config        branch.master.merge=refs/heads/master
file:.git/config        branch.dev1.remote=origin
file:.git/config        branch.dev1.merge=refs/heads/dev1
file:.git/config        branch.dev2.remote=origin
file:.git/config        branch.dev2.merge=refs/heads/dev2

解决方案

  • Is there a best practice, which parameters should show up in which config file?

This is totally up to you, whether you want a setting only on one repository, on all repositories you access with your user account or on all repositories on this machine (each time of course only if not overwritten from a lower config level).

  • I marked the parts which I can access via --system, --global and --local. Does anybody know where the first part belongs to?

As far as I remember these are the default values of the Git for Windows client and are on (or rather above) the system settings level. You can list and change them with git config --file c:\ProgramData\Git\config --list and so on.

  • Green is everything, where I think, it is ok (with my very limited knowledge).

As I said, totally up to you. The local green settings are most probably only useful on the local level, yes. For me user.email for example is not set on global level on my work box, as I work on private and corporate repos and use different addresses there. By not configuring either on the global level I am reminded on local level to set it when doing the first commit.

  • Red is strange as it exists twice

You can have each setting on each level, lower level overwriting value of upper levels, this is perfectly legal. You can e. g. set for all users on the system to use credential.helper=manager but for your user to use credential.helper=wincred like you have it in your example.

这篇关于Git配置文件:最佳做法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆