建设一个电商网站的流程图,资源最多的磁力搜索引擎,网站建设全网推广,设计软件下载Git 修改已提交的用户名和邮箱 修改上一次提交的邮箱和用户名
git commit --amend --author Nameemail批量修改多次提交的邮箱和用户名
新建一个 .sh 脚本在 git 根目录下.sh脚本内容如下
git filter-branch --env-filter
an$GIT_AUTHOR_NAME
am… Git 修改已提交的用户名和邮箱 修改上一次提交的邮箱和用户名
git commit --amend --author Nameemail批量修改多次提交的邮箱和用户名
新建一个 .sh 脚本在 git 根目录下.sh脚本内容如下
git filter-branch --env-filter
an$GIT_AUTHOR_NAME
am$GIT_AUTHOR_EMAIL
cn$GIT_COMMITTER_NAME
cm$GIT_COMMITTER_EMAIL
if [ $GIT_COMMITTER_EMAIL 这里写你原来的邮箱 ]
thencn你想替换成的用户名cm你想替换成的邮箱
fi
if [ $GIT_AUTHOR_EMAIL 这里写你原来的邮箱 ]
thenan你想替换成的用户名am你想替换成的邮箱
fiexport GIT_AUTHOR_NAME$anexport GIT_AUTHOR_EMAIL$amexport GIT_COMMITTER_NAME$cnexport GIT_COMMITTER_EMAIL$cm在 git 根目录下运行即可
修改指定提交
上述脚本中实现了在所有的提交中的修改如果需要修改指定提交的用户名和邮箱则需要 利用指令git rebase -i中的reword将rebase暂停然后与指令git commit --amend配合修改用户名和邮箱
Note
The --env-filter option can be used to modify committer and/or author identity. For example, if you found out that your commits have the wrong identity due to a misconfigured user.email, you can make a correction, before publishing the project, like this:
git filter-branch --env-filter if test $GIT_AUTHOR_EMAIL rootlocalhostthenGIT_AUTHOR_EMAILjohnexample.comfiif test $GIT_COMMITTER_EMAIL rootlocalhostthenGIT_COMMITTER_EMAILjohnexample.comfi-- --allTo restrict rewriting to only part of the history, specify a revision range in addition to the new branch name. The new branch name will point to the top-most revision that a git rev-list of this range will print.
Consider this history: D--E--F--G--H/ /
A--B-----CTo rewrite only commits D,E,F,G,H, but leave A, B and C alone, use:
git filter-branch ... C..HTo rewrite commits E,F,G,H, use one of these:
git filter-branch ... C..H --not D
git filter-branch ... D..H --not CAuthor Commiter
Author
为git log中的实际编写代码的人换句话说就是提交log到本地仓库的人。
Commiter
为将本地仓库push到远端仓库的人
通常情况下 Author 与 Commiter 为同一个人但是特殊情况下网络异常…比如 Author 无法将代码提交到远端仓库所以请 Commiter 帮忙push到远端仓库
参考
参考了以下链接在此做了一个更新和总结感谢各位 https://hufangyun.com/2018/git-change-user-info/ https://blog.csdn.net/weixin_30729609/article/details/96874653