安装好 Git 的时候,每个人都会设置全局的账户:

ZSH

1

2

git config --global user.name "laixintao"

公司的 Git 账户和个人的 Git 账户不一样,可以在项目中设置此项目的 Author :

ZSH

这样私人账户每次都要设置,可以设置一条 Git 的 alias ,这样每次需要将这个仓库的 author 设置成私人账户,只要敲一下 git private 就可以了。

Python

其实 git config --global 命令是修改的一个文件,$HOME/.gitconfig 例如我的文件如下:

Python

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

[core]

        editer = "/usr/local/bin/vim"

        editor = vim

        excludesfile = ~/.gitignore_global

[user]

        name = laixintao

        email = laixintao1995@163.com

        username = laixintao

[alias]

        pr = pullrequest

        ck = checkout

        br = branch

        lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

[merge]

        tool = vimdiff

        conflictstyle = diff3

[pull]

    rebase = true

[mergetool]

        prompt = false

[github]

        user = laixintao1995@163.com

[filter "lfs"]

        process = git-lfs filter-process

        required = true

        clean = git-lfs clean -- %f

        smudge = git-lfs smudge -- %f

同之前提到的 myrc 项目一样,gitconfig 这个文件我也是用 git 来追踪的,去一个新环境只要安装好这个项目就可以回到自己熟悉的 git 了。