Git/配置:修订间差异
来自康健生活
< Git
| 第69行: | 第69行: | ||
== 配置文件 == | == 配置文件 == | ||
配置文件有三种 | |||
* <nowiki>/etc/gitconfig</nowiki>: 系统范围内的配置文件,读取时加 <nowiki>--system</nowiki> | |||
* <nowiki>${HOME}/.gitconfig</nowiki>: 用户的配置文件,读取时加 <nowiki>--global</nowiki> | |||
* <nowiki>.git/config</nowiki>: 项目内配置文件(当前 git 工作目录) | |||
=== .gitconfig === | === .gitconfig === | ||
{{Hc|.gitconfig|<syntaxhighlight lang="text"> | {{Hc|.gitconfig|<syntaxhighlight lang="text"> | ||
2025年6月27日 (五) 12:55的最新版本
初始化
/home/kangkk
git init
用户设置
➜ ~
git config --list
credential.helper=osxkeychain
user.name=kangjian
user.email=kangjian@360.cn
--global
设置全局用户信息。
/home/kangkk
git config --global user.name "kangkk" && \
git config --global user.email "365@kangkk.com"
--local
单独设置项目内用户信息。
/home/kangkk
git config --local user.name "kangjian" && \
git config --local user.email "kangjian@360.cn"
设置编辑器
/home/kangkk
git config --global core.editor emacs
设置缩写
/home/kangkk
git config --global alias.co checkout
git config --global alias.l "log --graph --oneline "
git config --global alias.ls 'log --graph --pretty=format:"%h <%an> %ar %s"'
示例,查看 log 信息。
[jian@kang /home/kangkk]$
git l
* 7376210 (HEAD -> master, origin/master, origin/HEAD) 添加通过数据库查询最后版本号码的说明
* 2afdd49 添加通过数据库查询最后版本号码
...
* b7b05de 更新 https 证书
* f199050 Merge branch 'master' of git.a.b.net:qiwoo/xxx
|\
| * 44ad8c1 fix bug
| * 82685ae fix typo
| * 1dc08a2 fix typo
| * b5f5d7a 增加 ${HOSTNAME} 注入
| * 57e0681 更新日志位置
| * ae6b865 update think-logger 版本
* | 9ab1663 更新https的ssl证书
|/
* 6a54234 remove @2017
[jian@kang /home/kangkk]$
git ls
* 7376210 <kangjian> 6 周前 添加通过数据库查询最后版本号码的说明
...
* b7b05de <lizheming> 2 年 1 个月前 更新 https 证书
* f199050 <linxd> 2 年 2 个月前 Merge branch 'master' of git.a.b.net:qiwoo/xxx
|\
| * 44ad8c1 <lizheming> 2 年 3 个月前 fix bug
| * 82685ae <lizheming> 2 年 3 个月前 fix typo
| * 1dc08a2 <lizheming> 2 年 3 个月前 fix typo
| * b5f5d7a <lizheming> 2 年 3 个月前 增加 ${HOSTNAME} 注入
| * 57e0681 <lizheming> 2 年 3 个月前 更新日志位置
| * ae6b865 <lizheming> 2 年 6 个月前 update think-logger 版本
* | 9ab1663 <linxd> 2 年 2 个月前 更新https的ssl证书
|/
* 6a54234 <linxd> 2 年 6 个月前 remove @2017
配置文件
配置文件有三种
- /etc/gitconfig: 系统范围内的配置文件,读取时加 --system
- ${HOME}/.gitconfig: 用户的配置文件,读取时加 --global
- .git/config: 项目内配置文件(当前 git 工作目录)
.gitconfig
.gitconfig
[user]
name = kangjian
email = kangjian@360.cn
[alias]
l = log --oneline --graph
.gitignore
.gitmodules
.gitignore
No categories