问题背景
当使用git clone下载大型项目的时候,有时候会有到一些问题,因此,需要提前设置好git的相关参数,便于下载源码研究学习
问题解决
# 格式化换行符
# 1.true: 提交时改成LF,检出时改成CRLF
# 2.input:提交时改成LF,检出时不改
# 3.false:提交时是什么就是什么,不改换行符,检出时也不改
git config --global core.autocrlf input
#设置压缩级别 0表示无压缩,-1为zlib默认压缩值,而1-9是速度大小集中的方案,最慢的是9
git config --global core.compression -1
#http超时设置:传输速率低于0才满足超时条件1
git config --global http.lowSpeedLimit 0
#http超时设置:传输时间超过999999s满足超时条件2。当条件1和2都满足后才会timeout
git config --global http.lowSpeedTime 999999
#设置缓存5G
git config --global http.postBuffer 5242880000
git config --global https.postBuffer 5242880000
#设置代理
git config --global http.proxy 127.0.0.1:7890
git config --global https.proxy 127.0.0.1:7890
#取消代理
git config --global --unset http.proxy
git config --global --unset https.proxy
git config大概说明:
usage: git config [<options>]
Config file location
--[no-]global use global config file
--[no-]system use system config file
--[no-]local use repository config file
--[no-]worktree use per-worktree config file
-f, --[no-]file <file>
use given config file
--[no-]blob <blob-id> read config from given blob object
Action
--[no-]get get value: name [value-pattern]
--[no-]get-all get all values: key [value-pattern]
--[no-]get-regexp get values for regexp: name-regex [value-pattern]
--[no-]get-urlmatch get value specific for the URL: section[.var] URL
--[no-]replace-all replace all matching variables: name value [value-pattern]
--[no-]add add a new variable: name value
--[no-]unset remove a variable: name [value-pattern]
--[no-]unset-all remove all matches: name [value-pattern]
--[no-]rename-section rename section: old-name new-name
--[no-]remove-section remove a section: name
-l, --[no-]list list all
--[no-]fixed-value use string equality when comparing values to 'value-pattern'
-e, --[no-]edit open an editor
--[no-]get-color find the color configured: slot [default]
--[no-]get-colorbool find the color setting: slot [stdout-is-tty]
Type
-t, --[no-]type <type>
value is given this type
--bool value is "true" or "false"
--int value is decimal number
--bool-or-int value is --bool or --int
--bool-or-str value is --bool or string
--path value is a path (file or directory name)
--expiry-date value is an expiry date
Other
-z, --[no-]null terminate values with NUL byte
--[no-]name-only show variable names only
--[no-]includes respect include directives on lookup
--[no-]show-origin show origin of config (file, standard input, blob, command line)
--[no-]show-scope show scope of config (worktree, local, global, system, command)
--[no-]default <value>
with --get, use default value when missing entry
详细配置帮助请使用:git config --help