git change email by filter-branch/set local git email

[lake@localhost linux-stable]$ git config --global alias.change-commits '!'"f() { VAR=\$1; OLD=\$2; NEW=\$3; shift 3; git filter-branch --env-filter \"if [[ \\\"\$\`echo \$VAR\`\\\" = '\$OLD' ]]; then export \$VAR='\$NEW'; fi\" \$@; }; f"

[lake@localhost linux-stable]$ cat  ~/.gitconfig
[user]
        name = Lake Hu
        email = lake@localhost
[alias]
[alias]
    
        change-commits = "!f() { VAR=$1; OLD=$2; NEW=$3; shift 3; git filter-branch --env-filter \"if [[ \\\"$`echo $VAR`\\\" = '$OLD' ]]; then export $VAR='$NEW'; fi\" $@; }; f"
[kreatv]
        autoFormatSourceCode = true
[core]
        editor = vim
        autocrlf = input
[color]
        ui = auto
[lake@localhost linux-stable]$



Example:

[lake@localhost linux-stable]$ git log
commit 38b45955d1e2d33a43a7c0d4b03c295fbd0a9f38 (HEAD -> brcm_4.9.132)
Author: Lake Hu <lake@localhost>
Date:   Mon Nov 16 14:50:45 2020 +0800

    patch and kernel config

commit 63f0232cfc58c7fb19ea02cdd527f9a09193f37b
Author: Lake Hu <lake@localhost>
Date:   Mon Nov 16 14:45:01 2020 +0800

    4.9-1.10.tar.bz2, Dec 14 2018

commit 3622426cc93ab5bc75fa9cf2e897441dff894c34 (tag: v4.9.132)
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Wed Oct 10 08:53:23 2018 +0200

    Linux 4.9.132

 

[lake@localhost linux-stable]$ git change-commits GIT_AUTHOR_EMAIL "lake@localhost" "lake.hu@outlook.com" HEAD~3..HEAD
WARNING: git-filter-branch has a glut of gotchas generating mangled history
         rewrites.  Hit Ctrl-C before proceeding to abort, then use an
         alternative filtering tool such as 'git filter-repo'
         (https://github.com/newren/git-filter-repo/) instead.  See the
         filter-branch manual page for more details; to squelch this warning,
         set FILTER_BRANCH_SQUELCH_WARNING=1.



Proceeding with filter-branch...


Rewrite 38b45955d1e2d33a43a7c0d4b03c295fbd0a9f38 (3/3) (0 seconds passed, remaining 0 predicted)
Ref 'refs/heads/brcm_4.9.132' was rewritten
[lake@localhost linux-stable]$
[lake@localhost linux-stable]$
[lake@localhost linux-stable]$
[lake@localhost linux-stable]$
[lake@localhost linux-stable]$ git log
commit 92ba1220faf2a11b57b1f93abdad80e627c5dd47 (HEAD -> brcm_4.9.132)
Author: Lake Hu <lake.hu@outlook.com>		   ------------>  Changed 
Date:   Mon Nov 16 14:50:45 2020 +0800             ------------>  No change!!! 

    patch and kernel config

commit 193b8f69e010728a6028ba1971c872d3dd00f364
Author: Lake Hu <lake.hu@outlook.com>
Date:   Mon Nov 16 14:45:01 2020 +0800

    4.9-1.10.tar.bz2, Dec 14 2018

commit 3622426cc93ab5bc75fa9cf2e897441dff894c34 (tag: v4.9.132)
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Wed Oct 10 08:53:23 2018 +0200

    Linux 4.9.132

##############  set  local git email 

[lake@localhost linux-stable]$ git config user.email
lake@localhost


[lake@localhost linux-stable]$ cat .git/config
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
        fetch = +refs/heads/*:refs/remotes/origin/*
		
[lake@localhost linux-stable]$ git config user.email   lake.hu@outlook.com
[lake@localhost linux-stable]$ git config user.email
lake.hu@outlook.com
[lake@localhost linux-stable]$

[lake@localhost linux-stable]$ cat .git/config
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[user]
        email = lake.hu@outlook.com
[lake@localhost linux-stable]$


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值