在git初始化的时候可以进行一些配置。
我在用的主要的配置有这两个文件。
.gitconfig
git 核心配置的部分。
下面是我的常用配置,一次配置,以后可以一直使用,这个配置也可以添加到git去管理。
这样在多设备的时候都可以使用这一套配置。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
[core]
ignorecase = false
quotepath = false
excludesfile=C:/Users/user/.gitignore #指定全局的ignore的配置文件
[user]
email = email
name = name
[alias]
ad = add
br = branch
cc = checkout --
cf = config
ck = checkout
cm = commit
cl = clone
df = diff
fe = fetch
ps = push
me = merge
pl = pull
sb = submodule
ss = status
sw = switch
re = remote
unstage = reset HEAD
last = log -1
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
|
.gitignore
全局ignore配置
有些公共的忽略文件可以添加到这里,比如前端常见的dist 和 node_modules
1
2
3
4
5
6
7
8
|
dist
node_modules
# ide相关的ignore可以全局配置,这样省的到每个项目里都去ignore一遍,不过其实最好还是在项目里有自己的gitignore去配置,毕竟还是要多端多设备配置的嘛,不过也可以把配置都用git进行管理。
.idea
.vscode/*
!.vscode/extensions.json
|
git ignore 文档 gitignore
初始化必配置的ssh config
~/.ssh/config
不算是git的但是很重要一个配置,ssh连接配置,不用账号密码就能拉项目,快乐管理项目。
用一个ssh key 管理所有的git站点,然后就可以快乐的开始push & pull了。
参考配置文件 ssh client config
github ssh config preview
1
2
3
4
5
6
|
Host github.com
User git
Hostname github.com
IdentityFile ~/.ssh/[你的ssh_key]
ProxyCommand ncat --verbose --proxy-type socks5 --proxy 127.0.0.1:10808 %h %p
|
不需要代理日志信息的话,移除 –verbose