美文网首页
根据项目设置不同的git提交author

根据项目设置不同的git提交author

作者: 等你足够强了再说吧 | 来源:发表于2022-05-07 07:11 被阅读0次

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

    git config --global user.name "toptree"
    git config --global user.email "793059909@qq.com"
    

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

    git config user.name "toptree"
    git config user.email "toptree-private@163.com"
    

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

    git config --global alias.private 'config user.email "toptree-private@163.com"'
    

    命令执行的效果:

    localhost:~ root$ cat .gitconfig
    [user]
            name = toptree
            email = 793059909@qq.com
    [alias]
            private = config user.email \"toptree-private@163.com\"
    

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

    
    [core]
            editer = "/usr/local/bin/vim"
            editor = vim
            excludesfile = ~/.gitignore_global
    [user]
            name = toptree
            email =toptree-public@163.com
            username = toptree
    [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 = 793059909@qq.com
    [filter "lfs"]
            process = git-lfs filter-process
            required = true
            clean = git-lfs clean -- %f
            smudge = git-lfs smudge -- %f
    

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

    idea-git-author

    相关文章

      网友评论

          本文标题:根据项目设置不同的git提交author

          本文链接:https://www.haomeiwen.com/subject/spyturtx.html